TotallyNotChase / glitch-this

:camera: Glitchify images and GIF - with highly customizable options!
MIT License
1.75k stars 63 forks source link

How to create smaller gif size output #23

Closed lljr closed 4 years ago

lljr commented 4 years ago

I'm running mostly glitch_this -c -g -st 5 -i 1 <file>.JPG 3 and these images weight mostly up to 400kb. They're all JPEG but the result creates up to 200MB sized gifs... How can I reduce the size of the output? Are there any flags?

EDIT: I was able to reduce by dropping frames but the output is still big tbh (20MB).

TotallyNotChase commented 4 years ago

This is due to compression. Due to how PIL and GIFs in general work. More compression can drastically reduce size at the cost of GIF quality and also runtime speed, compression takes a massive amount of time. I really like high quality glitched gifs as I use them a lot so I reduced the compression down from PIL's default 6 to just 3. See here and here

Now, to address this issue. I'm not sure adding a flag for compression would be a good idea as that's a bit out of scope for this project. There are ofcourse websites, that support GIF editing, as well as client side tools. Also, it'd be difficult to settle on a default compression size. Because of all its tradeoffs. Personally, I head to ezgifs for compressing my GIFs if they are too large.

Something to note, this utility does come with a library, which can be used to enhance this very feature. Upon calling the glitch functions through the library, it'll return a PIL image object. The user can then compress it however they want, at the cost of their own program's runtime speed. This way the user can, not only raise the compression level but also use PIL's .resize and other such methods. I cannot give that kind of functionality in a commandline script though because that'd be completely out of scope.