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

expose indexed color profile for PNG #1286

Closed
Hugo-Trentesaux opened this issue Jul 21, 2020 · 6 comments
Closed

expose indexed color profile for PNG #1286

Hugo-Trentesaux opened this issue Jul 21, 2020 · 6 comments
Labels
kind: enhancement topic: meta data Towards dealing with meta data

Comments

@Hugo-Trentesaux
Copy link

It was discussed in #389 that exposing indexed color profiles of PNG crate could be done quite easily. A use case is given here for light thumbnail generation in Zola ssg. It can significantly decrease media size and then produce much lighter web pages.

@HeroicKatora
Copy link
Member

HeroicKatora commented Jul 22, 2020

The one thing that's not clear to me is interface. We could add a method of PNGEncoder which does the conversion internally. An alternative is to add a method that switches the mode to prefer indexing, which would only expose the high-level goal of producing small images without giving specifically that this is done via indexing. This would have the advantage of providing some parameter for the acceptable loss of image fidelity that might occur as part of color mapping. Yet another alternative would be to add an interaction with ColorMap in some capacity.

@HeroicKatora HeroicKatora added this to New Features in Version 0.23 Aug 29, 2020
@HeroicKatora HeroicKatora added the topic: meta data Towards dealing with meta data label Mar 12, 2021
@fintelia fintelia closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2024
@Hugo-Trentesaux
Copy link
Author

@fintelia is this "not planned" as in "not planned yet" (which I would understand) or "not planned" as in "planned not to", for which I would like to know more about.

@fintelia
Copy link
Contributor

It is more "not planning to add an API for this to the image crate". I'd support adding the logic to the png crate to automatically write indexed PNGs when it improved the compression ratio

@Hugo-Trentesaux
Copy link
Author

Well, it always improves the compression ratio, the problem is that depending on the image it can lead to visible posterization artifacts. That's why using a color palette is a user choice more than a technical decision that could be automated.

@fintelia
Copy link
Contributor

I guess there's two different features here:

  1. Automatically detect if an image uses <=256 colors during encoding. If so, write a paletted PNG.
  2. Do lossy encoding by reducing the image to only use 256 colors.

I'm supportive of implementing (1) in the png crate. (2) feels much more specialized though, so probably would require more discussion. And in any case, that's probably not a common enough feature that it needs to be exposed in this crate rather than just being available in the format specific crate.

@Hugo-Trentesaux
Copy link
Author

Ok, I understand better now. I'll file an issue in the png crate and see their thoughts about it. But guessing if an image uses less than 256 colors can fail due to edge anti-aliasing which introduces a lot of intermediate colors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement topic: meta data Towards dealing with meta data
Projects
Version 0.23
  
New Features
Development

No branches or pull requests

3 participants