-
Notifications
You must be signed in to change notification settings - Fork 619
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
An improved ImageOutputFormat
design
#1380
Comments
Two points of feedback:
|
Depends where they are located. If they are in the codecs::png/codecs::jpeg etc. modules, it'd be confusing. If they were in a top level |
As an alternative, one can also add pub enum ImageOutputFormat {
#[non_exhaustive]
Png,
#[non_exhaustive]
Jpeg(u8),
#[non_exhaustive]
Pnm(PNMSubtype),
Gif,
#[non_exhaustive]
Ico,
#[non_exhaustive]
Bmp,
#[non_exhaustive]
Farbfeld,
#[non_exhaustive]
Tga,
#[non_exhaustive]
Unsupported(String),
// some variants omitted
}
The issue with this is that different libraries interpet the value differently. A quality setting of 5 can be sth different for avif from a quality setting of 5 jpeg. Same goes for speed. Not even sure the scales are linear.. |
I think the right approach is to have an enum with semantic options rather than trying to have a linear scale. We could cover most of the common cases just with: enum EncodeQuality {
VeryFast,
Fast,
Balanced,
HighQuality,
VeryHighQuality,
} |
The
That sounds a bit problematic in itself. A common interface for all types would be better. Prior art: the list of presets supported by ffmpeg/x264 which for some reason is not symmetrical. Over time I would like to see some quantifiable and queriable value for the difference between two settings in terms of speedup (also visual fidelity but that is hard to quantify) but that's for some far future and by no means necessary. (edit: The simple design of @fintelia would probably suffice). |
I'm very much a newbie to this, but would it be possible to eventually have a scale for visual fidelity loosely based upon SSIM values? I saw this file which tries to roughly map jpeg quality levels to ssim values, not sure what encoder they're using for it. Each codec could then have a hashmap for which quality setting loosely maps to a visual quality tier? |
I'm realizing that for many formats there are actually three dimensions we can trade off between: speed, compressed size, and image quality. Not sure the best way to encode the different options between those |
Yeah that's why I was thinking about having a separate options struct for every format. Every format would then implement
I'm ok with just calling it |
For what it's worth, I quite like the initial suggestion in this issue, the enum of To be able to handle some kind of generic encoder options, why not just have a separate type If the name |
Another solution that comes to mind for the next version could be something like this:
Originally posted by @paolobarbolini in #1152 (comment)
The text was updated successfully, but these errors were encountered: