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
Quantize tiny images #3466
Comments
@tmcw - I guess if quantising small images like that makes sense then patch is welcome. My thinking was- palleted image from < 3 pixels is somewhat less efficient than original |
Given that palleted images would be larger, could we replace the thrown exception with a call to the |
Yes, exactly |
I think saving with a 1- or 2-color palette would be more consistent. The function is supposed to produce an indexed image. If someone wants to avoid wasting the palette on tiny images, they can check before the call (and in that case, one would probably use a higher threshold, like > 4px total). |
@lightmare - fair point |
@tmcw - latest master supports tiny ( < 3 pixels) palette images ^ |
👍 awesome, thank you @artemp! |
tests added in b55f5dc closing |
We have a service that provides images that are quantized through Mapnik. The service advertises width 1-1024 and height 1-1024. When a user inputs a size of 1x1, it calls to
save_as_png_hex
and triggers a quantization error, since less than 3 pixels means too few for Mapnik's hextree strategy.Happy to work on a patch if this seems worthwhile - my first guess is that for < 3 pixel PNGs, the palette is the colors of the pixels verbatim
The text was updated successfully, but these errors were encountered: