Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
(Using version ImageMagick 7.0.5-10 Q16 x64 on Windows 10, convert.exe via command line)
I have a small batch of PNG files with transparent background that I want made into an animated GIF file. I'll provide them here for reference: https://files.catbox.moe/r1qu5c.rar
I get a GIF file that works as expected, but on some backgrounds appears highly aliased. On googling for solutions I have read things that implies that it's natural for GIF. However, I can do this in Photoshop without the result appearing aliased. Comparison here: http://imgur.com/a/FrIdk
Unfortunately, Photoshop is not an option for me as I need this to be doable via command line. If somebody could help me out, I'd be really grateful.
Gif does not support 8-bit transparency. It only allows binary transparency. So that is why you get the noticeable aliasing in the gif output. There is nothing that can be done about as far as I know other than to create your animations as video (mpeg, etc) and not use gif animation. ImageMagick supports MPNG, but not APNG for animation, I believe. But MPNG is not very portable.
fmw42 wrote: ↑2017-06-08T13:30:31-07:00
Gif does not support 8-bit transparency. It only allows binary transparency. So that is why you get the noticeable aliasing in the gif output. There is nothing that can be done about as far as I know other than to create your animations as video (mpeg, etc) and not use gif animation. ImageMagick supports MPNG, but not APNG for animation, I believe. But MPNG is not very portable.
As I mentioned, I read explanations along these lines before coming here. However, both files in my comparsion are gif. The one made with Photoshop doesn't have this issue.
Post both files to some free hosting service and put the URLs here so we can examine them. Also post your exact IM code or better the equivalent as a command line.
EDIT: sorry, I did not see you had posted that above.
Sorry, I tested your data and get the expected aliasing due to gif binary transparency. If you are willing to replace the transparency with some color, then each file can be flattened against the background color and the gif animation created from them, which should not have aliased edges, since there is no transparency.
Unfortunately, I do not know how you created your animation in Photoshop, so cannot comment on how they are able to avoid that issue. Nor do I know enough about GIF transparency. Perhaps some other tools can created 8-bit gif transparency, but IM will not, to my understanding.
glennrp is the GIF expert here. Perhaps he can comment further or correct my understanding.
I simply imported all the frames in as layers and then used the "make frames from layers" feature, on Photoshop CS3.
Thank you for the information on how Photoshop does it. I'll try looking into other options.
If I flatten each PNG against a black background, then make the animation, it shows no aliasing as I mentioned above. I chose black since the color under your transparency in the PNG was black, so any antialiasing was against a black background. However, I tried a white background and that worked fine also. So the color probably does not matter.
Here I use subshell processing in Unix (Mac OS X) to avoid having to save each new PNG image before making the animation. I called your folder of images, data. Curious why there is no imagename001.png?
Thanks again. This definitely works. However, my idea is to retain transparency, so this is a little less than ideal. I'm looking into some other ways to go about this now, so I'll report back if there's any progress, just in case someone else might also want to do something like this.
Also, the files were originally 001 to 017, and 001 was actually the last frame, so I just renamed it to 018 for convenience.
As Fred says, gif alpha is binary (either 0 or 100%), but the input PNG files have values across the full range. Some experimentation on just the first frame shows that PS thresholds alpha at 50%, and IM doesn't, so:
snibgo wrote: ↑2017-06-09T00:10:17-07:00
As Fred says, gif alpha is binary (either 0 or 100%), but the input PNG files have values across the full range. Some experimentation on just the first frame shows that PS thresholds alpha at 50%, and IM doesn't, so:
That is a good point. But I tried it in my scripting and it does not seem to make much difference. I still cannot figure out exactly how PS matte works to mitigate aliasing for transparent images