kornelski / cavif-rs

AVIF image creator in pure Rust
https://lib.rs/cavif
BSD 3-Clause "New" or "Revised" License
582 stars 29 forks source link

avif can't keep icc profile and other metadata #15

Open Lee-lithium opened 3 years ago

Lee-lithium commented 3 years ago

Hello, kornelski cavif-rs is work very well, file size and quality is amazing :), but compressed avif can't keep icc profile and other metadata, probably can add a flag to handle icc profile and other metadata?

kornelski commented 3 years ago

I'm planning to apply color profiles in order to convert pixel data to one of color spaces already supported by AVIF.

OTOH embedding ICC in AVIF would be an anachronism and a waste of space. To me profiles are only a workaround for crappy old 8-bit formats that can't represent wider gamut otherwise. AV1 supports Rec. 2020, HDR, and high bit depths natively, so ICC profiles are just a waste of space, processing and needless loss of precision.

Lee-lithium commented 3 years ago

Thank you for your reply kornelski :) Actually i want use avif like this method(png, jpg => avif =>png), so i need icc profile to make sure my decode png can keep same color space,

And a little curious, av1 rav1e encoder probably can use ycocg(--nclx 1/13/0)? use ycocg on png file, can let avif file color space more accurate.

kornelski commented 3 years ago

I haven't finished implementing ycocg, and once I've realized it needs 9 bits to be lossless I'm not in a rush. 10 or 12 bits in another color space could be precise enough? It's still a lossy compression anyway.

As for conversion to png, an AVIF decoder should generate a new ICC profile if necessary, based on what color space AVIF used. If AVIF can store 10 or 12 bit Rec 2020, that should be more than enough for any profile. Then you can decode to 16bit png with Rec 2020 ICC or something smaller if you have a smart converter. For 8 bit png I would not bother with anything larger than sRGB, regardless of ICC support.

WebMechanic commented 2 years ago

OTOH embedding ICC in AVIF would be an anachronism and a waste of space. To me profiles are only a workaround for crappy old 8-bit formats that can't represent wider gamut otherwise.

Well, as long as 8-bit raster formats and devices are the dominant species on the web and in consumer's hands using and presuming sRGB only is the worst possible solution to the problem - no matter what you think about it and the world won't change just because of your personal opinion. It's not ideal, granted, but it's reality and reality needs workarounds until your Image Utopia is here.

Most people don't have time (or knowledge) to fiddle with images: they want their "good looking 8-bit consumer JPEGs" to become good looking AVIFs - just with less data, because they were told it's nice to use less data for virtually the same image quality. They understand that. If their images look flat, they klick the "Auto Correct" button, crank up the contrast, destroy the image data in the process and "Save to Web": Image looks good to me. Upload. End of story.

If the image you tool creates looks like shit to many people, they won't use or recommend your tool and promoting AVIF will become harder, because for Jane and Joe Average "AVIF images always look like shit". Well done, sir! 👏🏻

You might be blessed with a perfectly calibrated HDR wide gamut screen, but mere mortals unfortunately have crappy 8-bit screens on their desks and in their hands and those that produce content for these people need a working and practical solution. Properly tagged images are a solution for those that do bother to give their audience the best possible image for their consumer devices -- and not necessarily the perfect.

Even high-end RAW footage is "flawed" and editing such footage always requires the colour profile of the camera that took the footage (image or video) to allow any target device to display as much of the image data as possible (colours and dynamic range). Same issue. Software the does the processing needs these profiles to deliver the best possible image for these different crappy targets, because there's no perfect image source to begin with let alone the perfect target device to watch it. There's no such thing as the "correct" colour for any pixel, which is why colour profiles are required to translate between image data and image display: you should know that, so please don't be ignorant about it and call it an "archaic concept". Reality is what it is.

There's also no need to "waste data" by embedding the whole profile anyway. If it's a well known and common profile available for virtually all devices and any image and video processing software, the maximum about of bytes wasted are those for the ICC tag.

Thanks for the software, anyway. And please add effing ICC support FFS.

Have a good time. 👋🏻

kornelski commented 2 years ago

Your rant is not appropriate here, both for its tone, and for beating a technically-inaccurate strawman.

zachlewis commented 1 year ago

Hey @kornelski --

kornelski commented 1 year ago

@zachlewis As far as I know, Rec. 709 has the same primaries and white point as sRGB, only the gamma differs. But when encoding to 10-bit depth there should be enough precision left to convert from ~2.2 to 2.4. To support this I'd just need to accept higher-depth inputs.

There also is a constant for Rec. 709 gamma in AV1 metadata, so even that doesn't need ICC.