Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on gifsicle which implements lossy LZW compression.
It can reduce animgif file sizes by 30%—50% at a cost of some dithering/noise.
--lossy
option that allows inexact match against LZW dictionary, which improves compression ratio.Lossy matching does a bit of 1-dimensional dithering.
This is a very basic implementation that does recursive search of dictionary nodes.
write_compressed_data
contains some duplicated code, because the lossy search function needs to use less optimized code (ignoresimageline
), although this probably could be refactored a bit.The results are pretty good:
Original: 3.3MB
![fat smooth anim](https://cloud.githubusercontent.com/assets/3759759/16902378/a49eff78-4c65-11e6-9956-a9895fe53dfc.gif)
Lossy: 1.25MB
![noisy small anim](https://cloud.githubusercontent.com/assets/72159/2561581/f5e618e0-b81e-11e3-9243-2f8d8cb18e5d.gif)
Closed: #16