Make your Pixel-art interpolation look better with Dain-app and Gimp (and some other software)

Pixel-art in DAIN tend to have a number of issues. I will describe here methods to fix all those problems. We will be manipulating gifs in the Gimp editor, but Graphicsgale or Asesprite work well too.

Free softwares:

Gimp: https://www.gimp.org/

Graphicsgale: https://graphicsgale.com/us/

 

The very basics:

  • Use GIF output
  • Use Limit Color Palette
  • Use Alpha Transparency
  • Do not go above 50fps

 

Contents:

0) Common pixel-art issues and solutions

1) Prepare your Pixel-art animation : prerequisites

2) Send you animation to Dain-App

3) Import your Pixel-art cleanly from PNG frames

4) Pixelise back your image (optional)

5) Limit color palette with (optional)

E) Do it with scripts

 

0) Common pixel-art issues and solutions:

a) Blury output/lost pixel details/too much antialiasing

→ upscale first to conserve whole pixels (see 1.d to upscale, 4 to downscale)

b) Your output lost its transparency

→ select gif output or you forgot to turn on alpha+limit color palette (see 2 for common settings)

Known bug from 0.34: using mode 3 and 4 would also remove transparency. Fixed since then.

c) The colors are totally washed out with tons of dithering

→ select "Limit Color palette" to use the original color palette (see 2 for common settings)

d) Despite using Limit Color Palette, there are weird colors/dots

→ known bug fixed in 0.37: color dithering enabled by default, fix by converting png→gif manually (see 3 to make a gif, 5 to limit the color palette again)

e) Not aligned on pixels (not "pixel-art" anymore)

→ re-pixelize (downscale and upscale back) (see 4)

f) Your output is slower than expected

Gifs cannot go faster than 50fps (20ms per frame), otherwise their speed break and they go slowly.

One way to try to fix this is to change the "Input Framerate" entry to 50fps divided by the interpolation rate.

Another is to edit the speed of the gif by hand to be 20ms per frame, and remove some frames if it's still too slow. (see 3.b)

 

1) Prepare your Pixel-art animation : prerequisites

a) Your starting pixel-art should be crisp.

If it's already blury, there might be already too many colors for the later steps.
b) In V0.32, you need to have an animation (gif is recommended for pixel-art). Point 3 can help with that. Starting V0.33 you can use PNG frames (but the limit color palette is still buggy).


c) Make the background transparent.

Or use a color that is very far from any other color. Otherwise, your outline might become mixed with the background color. This is a must for sprites that will be shown on different backgrounds.
Unfortunately this is a tedious process in Gimp: https://www.wanderings.net/notebook/Main/CreatingTransparentGIFsGimp repeat this process for

each frame
However you could use a different software/site for that.
For example with Graphicsgale: click [...] above Frame, change [Current frame↓] to [All Frames], check Transparency → select transparent color, then save your gif

screenshot6copy.png

 

d) Upscale it crisp/nearest neighbour
This will allow your pixel-art to retain its shape even after passing trough DAIN. This is useful for low-detail pixel-art with plain color areas.

 

 

2rabbitdirectinterpolation.gif◄Dain Directly on 100% e07d49b601bf6d985c3b69ac4d0f7de1.gif | Upscale 400% first then Pixelise►4rabbitupscaledinterpolationpixelated.gif

Graphicsgale: All Frames→Resample→By Percent→400%, unckeck "Smooth" (we want rough, crispy nearest neighbour)
Gimp: Image → Scale Image → set the values: Change to "percent" and try 400% or 800%, Change the Interpolation: None (/!\ Important to keep the pixels crisp) → Scale. To save as gif, you have to go to  File→"Overwrite"/"Export As"

screenshot18.png

Asesprite: Sprite→Sprite size:400% or 25% with Lock Ratio, Nearest Neighbour Yes

 

2) Send your animation to Dain-app

a) Options for basic gif output:

Export as GIF, Limit Color Palette, Alpha transparency: yes (either method is fine)
Note: alpha transparency on gif output will only work if you select Limit Color Palette.


b) Prefer mode 1 if your animation has constant framerate, mode 4 if it doesn't.

screenshot7.png

The GIF created by Dain-app is fine in most cases.

However, currently it has dithering enabled by default which can create some noise (future versions might fix that).

32f9430eace73bdf67f52e792c2d126f.gifThe dithering pattern is visible as noise and displaced colors a4e5b167de6645aa9b5fb286f30fdfee.png

If this is an issue for you, I can suggest you to create the gif animation yourself using the png frames in the interpolated_frames folder. See 3)

If you upscaled your animation before sending it to DAIN, you will have deformed pixels. You can fix that by downscaling and upscaling back your image. See step 4.
Edit: As of version 3.7, Dain-App disables dithering by default.

 

3) Import your Pixel-Art cleanly from PNG frames

(in case you can't stand the dithering noise)

Gimp:
a) Open the frames as animation:

File → Open as Layers (Ctrl+Alt+O) → go into folder "interpolated_frames" (drag-and-drop) and select every file (Ctrl+A) → Open /!\ It may take a while!
b) Save as Gif

File → Export As (Ctrl+Shift+E) → select another place → set the format as yourFilename.GIF → Export
Export Image as GIF:
[X] As animation [X] Loop forever
Put the wanted delay (lowest is 20ms per frame (50fps) for Gifs, lower they start slowing down)
Change Frame disposal → One frame per layer (replace) /!\ IMPORTANT
Select the two last checkmarks if you are changing the disposal and framerate of an existing gif (not mandatory).

screenshot13.png

The generated gif will not have its colors limited like what DAIN outputs.

 

Asesprite:

To open several png files as animation, do:

Open→Click on the first image of the animation. It will automatically ask you if you want to open the rest.

Graphicsgale:

File→Import from Multi Files...→Add:select all your frames→OK
If your pngs have transparency:
File→Properties: Check "Single Palette": Yes. Background-color: set it to a color that does not appear in your images. Your color should now appear in the transparent areas.

Click "[...]" on Frame (Properties). Change Current Frame to All Frames. Check Transparency color and set it to your color if you have one. Set Delay for wanted duration. →OK
Save As→Save as type:gif, Limit Color palette→OK

 

If you created your gif this way, you will see that it is not using the original color palette anymore. To load back the original color palette, see step 5.

 

The next two optional steps (4 and 5) can be done in any order. Scaling it first or reducing the colors first might give different results in some programs.

 

4) Pixelise back your image (optional)

Similar to step 1.d) 

a) If you upscaled your image for pixel-art details and you want true pixels, you need to pixelise it back now, by doing Scale Image by the opposite value (25% for 1/4, or 12.5% for 1/8), with Interpolation: None (crisp)

b) If you want your gif preview to look bigger, you can do Scale Image again with the desired zoom (400%, etc).

5933ad5c593ee79fe1482f8e30b7959a.gif◄Before Pixelisation | After Pixelisation►266127d6f51cb86249f15ca2a69c1ca1.gif

You can do this on the DAIN-generated gif too.

 

5) Limit color palette with (optional)

Gimp:
a) Have the target animation you want to limit the color of open (either the one you imported PNGs in, or the gif you created)
b) Open the ORIGINAL gif from which you want to copy the palette (source) with File → Open (drag-and-drop on the Open Image dialog)
/!\ Simply drag-and-dropping on Gimp will add it to your current image instead, which is not what we want!
c) Go on the target animation you want to reduce the color palette of and do:
Image → Mode → Indexed... (if already indexed, put it first in RGB, then back to Indexed...)
"Convert Image to Indexed Colors" → (•) "Use custom palette" → click on the palette and select "Colormap of Image #" that corresponds to the source gif (near the top)
Dithering → Color dithering: None /!\ Important

screenshot17.pngYour image should now have the same palette as the beginning image.

You can even use unrelated images to generate palettes!
d) Export as yet another gif (as you might prefer the other version):
File → Export As (Ctrl+Shift+E) → otherFilename.GIF → Export

Asesprite:

Open an image with only the colors that you want to limit to (one of the original files). Copy the palette (including transparency)

Open the image you want to apply the palette to. Replace the full palette with the limited palette. Go to sprite→Color Mode→Indexed.

Graphicsgale:

Limit the palette to a specific frame's:
Close and open your gif back.
If the transparency color reverted to one in the image, change it via the palette on the right, because otherwise the palette info will be merged in the next step.
File→Properties→Uncheck Single palette
All Frames→Color Depth→256
Go on a frame that has the original limited palette (usually, first frame)
File→Properties→Check Single Palette, select "Apply current colors (match pixel with color)"

 

----

 

Select your prefered image out of all the generated animations !

Sometimes it is not necessary to do every step.

If you have questions, you can visit DAINApp's Discord https://discordapp.com/channels/668789174257844225/668789174861561868

 

Extra) Do it with scripts

 

https://github.com/akirbaes/_AutoDain

I have written scripts that do the upscaling and sending to DAIN and retrieval automatically. Just requires Python and some modules (PIL/Numpy).
Also take a look at https://github.com/akirbaes/giftools for a bunch of scripts for gifs manipulations.

I also recommend gifsicle for unoptimising gifs, which can sometimes solve broken gif issues.