Skip to content
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

Closed
tmcw opened this issue Jul 12, 2016 · 8 comments
Closed

Quantize tiny images #3466

tmcw opened this issue Jul 12, 2016 · 8 comments
Assignees

Comments

@tmcw
Copy link
Contributor

tmcw commented Jul 12, 2016

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

@artemp
Copy link
Member

artemp commented Jul 12, 2016

@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

@tmcw
Copy link
Contributor Author

tmcw commented Jul 12, 2016

Given that palleted images would be larger, could we replace the thrown exception with a call to the save_as_png?

@artemp
Copy link
Member

artemp commented Jul 13, 2016

Yes, exactly

@artemp artemp self-assigned this Jul 13, 2016
@lightmare
Copy link
Contributor

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).

@artemp
Copy link
Member

artemp commented Jul 18, 2016

@lightmare - fair point
/cc @tmcw

@artemp
Copy link
Member

artemp commented Jul 20, 2016

@tmcw - latest master supports tiny ( < 3 pixels) palette images ^

@tmcw
Copy link
Contributor Author

tmcw commented Jul 20, 2016

👍 awesome, thank you @artemp!

@artemp
Copy link
Member

artemp commented Aug 1, 2016

tests added in b55f5dc

closing

@artemp artemp closed this as completed Aug 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants