-
Notifications
You must be signed in to change notification settings - Fork 0
add new flag -g to compress gifs #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add new flag -g to compress gifs #32
Conversation
add gif compression by quantization to 32k colors in debug leave console open until readline for easy log reading
|
LGTM |
| //images.Optimize(); | ||
| //images.OptimizeTransparency(); | ||
| //reduce color bit depth from 8 to 5. | ||
| images.Quantize(new QuantizeSettings() { Colors = 32768 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 32768 ?
any special meaning ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
15-bit high color ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes (2^5) bits per red, green, and blue 32*32*32 = 32k colors. Normal 8 bit per channel can support: 16777216 colors.
pinzart90
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
@mjkkirschner I thought that gifs never worked for documentation. Is it that after this change they now can be rendered or were they always supported and this is only for compression? |
This PR fixes an issue where animated gifs were not optimized at all. There are a few issues.
gifs/animated gifs are quite complex - if they have been optimized before using certain methods -they cannot be optimized again - for example, if they contain frames with different internal sizes. (an optimization technique)
it's possible to undo this and then optimize with image magick, but I found this to be too slow ~ 10 minutes for 40 gifs.
Instead I found that using quantization (color reduction to 32k colors) works very well, is quite fast, and produces results about 10% - 50% reduction per gif.
running the tool on RevitNodes.dll and Revit dictionary takes 33 seconds before this change, and 99 seconds after this change - the folder is reduced from 44megs to 38 megs. (we don't have that many .gifs in the Revit dictionary content today, only 40.)
because reducing the .gif's is still quite slow overall, and⚠️ ❗ not lossless I added a separate flag for it, this is handy for quickly debugging other parts of the tool or avoiding the gif image changes.
also now in debug mode leave console open until console.readline for easier log reading.
this is a pathologically bad example because it has a ton of colors used in the animation.
1Meg

900kB
