General-purpose GIF editing command-line library gifsicle. In thisĮxample, we apply the described method to a given GIF my_gif using pygifsicle, a porting of the Used here) is saving just the differences between the following frames. GIF files can be compressed in several ways, the most common one method (the one When the process is finished and the GIF is unexpectedly big. This can be useful when theĮlaboration process for the GIF is not finished yet (for instance if someĮlaboration on specific frames stills need to happen), but it can be an issue Heavy, as the created GIF is not optimized. When creating a GIF using imageio the resulting images can get quite Here's a copy of the gifsicle command from that guide: gifsicle -O3 -colors 256 Almost.gif > Done.gif. imwrite ( output, img, plugin = "pillow", extension = ".jpeg" ) Optimizing a GIF using pygifsicle # Would really appreciate any advice from people who use the CLI for this kind of image manipulation. imwrite ( output, img, plugin = "pillow", extension = ".png" ) # write as JPG output = io. imread ( 'imageio:astronaut.png' ) # write as PNG output = io. Worth noting though.Import imageio.v3 as iio import io # load an example image img = iio. If so, I’m not sure what ffmpeg and gifsicle are doing to make it work correctly.īig deal? Maybe, maybe not. From what I understand, the gif format itself does the 100th of a second rounding. Apparently you can specify units precisely, like -delay 33,1000 for 33/1000’s of a second, or even -delay 333,10000 for 333/10000’s of a second. I tried some other formats for the delay parameter. Specifically, a 300 frame animation set to run at 30 fps should run for 10 seconds, as the ffmpeg and gifski gifs do. Somehow, the gifs created with ffmpeg and gifski do seem to run at the exact fps specified. So they’ve actually been running a bit faster than 30fps. But it turns out it just puts a delay of 3/100’s of a second. Anyway, I’ve been using a delay of 3.33 to make them run at 30 fps. To my eye, they seemed like the same gif, with one exception – duration.Īctually I discovered today that ImageMagick’s delay property will truncate decimal arguments. I didn’t see any quality issues in any of them. A note on quality and durationĪll of the gifs produced seemed to me to be of very comparable quality. Full color source images could change everything. I should also note that all my tests have been on grayscale animations. I’ll be using it a lot more in coming weeks and days and update with any new findings. If you are dealing with gifs as your source image sequence, gifsicle might be a good compromise.īut I think the overall winner is gifski in terms of hitting that sweet spot. If you are going for speed, nothing beats ffmpeg. If you are going for size, nothing beats ImageMagick, but it takes forever. Gifsicle: with image conversion needed, way too long Size: ImageMagick: 13 mb Here’s the results I got: Time: FFMPEG: 5.780 s Not as small as ImageMagick’s output, but way faster. Not as fast as ffmpeg, but image sizes are way smaller. Performance-wise, it hits a pretty sweet spot. I don’t think I really need to explain any of that. And it’s written in Rust, which tends to give projects a lot of street cred these days. As for size, it was almost right in between the sizes produced by ImageMagic and ffmpeg.īut the additional conversion process put this one out of the running for me. destination'imageio3. However, if runtime is important, I recommend gifsicle: gifsicle ( sources 'imageio1.gif', 'imageio2.gif', or just omit it and will use the first source provided. I didn’t time it, but I feel like it was more than a minute for 300 frames. This completes in 15.6 seconds for two GIFs, each containing 100 frames. OK, I was able to put together a quick ImageMagick script to convert all my pngs to gifs. Big drawback on this workflow though: the source images have to be gifs themselves. I think it would be better to do this in the palette creating stage.īut gifsicle can also create gifs from a sequence of images, just like ImageMagick and ffmpeg. This got considerable results, but at a loss of quality. You can also use gifsicle to reduce colors in an existing gif. The highest level took a single megabyte off of a 27 mb gif. You can specify three levels of optimization. I tried it on some of the larger ffmpeg-created gifs and it didn’t seem to do a whole lot. I first heard about gifsicle a while ago as a tool to optimize gifs. I’ve been continuing my search on the ultimate gif-making workflow and came across two more tools.īoth of these are command line tools available across platforms.
0 Comments
Leave a Reply. |