Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.72k stars 311 forks source link

RawTherapee fails to save PNG file with ProPhoto profile #5690

Open teplit opened 4 years ago

teplit commented 4 years ago

RawTherapee 5.8 creates zero bytes PNG file with an error message when the Output Profile is ProPhoto.

Steps to reproduce the problem:

  1. Open a RAW file
  2. Switch to Neutral Processing Profile
  3. Set ProPhoto as Output Profile
  4. Try to save 8 or 16 bit PNG file (Ctrl+s)

Tested on two computers - one with Windows 10 (1909) and the other with Windows 8.1.

gaaned92 commented 4 years ago

Do you have a precise use case to do that? PNG format is just good to screen capture or web app. For photos, if you need losseless format, just prefer Tiff format. Furthermore, even would it work, ICC profile would not be included, making the file useless. Some app have a workaround putting exif data in a PNG chunk, but it's just a kack as it is not standardized.

teplit commented 4 years ago

RawTherapee 5.8 saves successfully PNG files with the following color profiles (the list is not exhaustive):

Apparently PNG is a first class format in RawTherapee.

teplit commented 4 years ago

I’m not a PNG format expert. However I did a simple experiment in order to see where exactly RawTherapee stores the ICC profile in a PNG file. With the aid of TweakPNG I did the following:

  1. From RawTherapee I exported 16 bit PNG file with RTv4_ACES_AP0 profile.
  2. I opened the file in TweakPNG and deleted the tEXt chunk, which apparently is used to store the EXIF data. The PNG specification does not specify a formal place for EXIF data. However in an official extension of the PNG specification version 1.2 dating from 2017, the new eXIf chunk is introduced exactly for that purpose - http://ftp-osl.osuosl.org/pub/libpng/documents/pngext-1.5.0.html#C.eXIf
  3. I saved the modified PNG file.
  4. I opened the modified PNG file with Adobe Photoshop CC.
  5. Photoshop displayed the image correctly and showed RTv4_ACES_AP0 as profile.

Why this works? RawTherapee writes the ICC profile in an iCCP chunk, and Photoshop recognizes that chunk. Guess what will happen if you delete the iCCP chunk…

Is this a hack? No, it is not – the iCCP chunk is part of the PNG specification - http://www.libpng.org/pub/png/spec/iso/index-object.html#11iCCP

Is the EXIF data important to keep in an exported image from RawTherapee? For me it is not. Something else - the EXIF data can cause privacy problems if it contains GPS data and real names, and for “professionally processed” photos that look more like paintings than photographs it is practically irrelevant.

Are PNG files useful only for screenshots and web graphics? They are useful for many more things – for example computer generated graphics with more than 8 bits per channel.

The failure of RawTherapee to save PNG file with ProPhoto profile is a manifestation of defect.

teplit commented 4 years ago

Something more – the EXIF does not record what filter (or combination of filters) you used in front of your lens and what extension tube (or combination of extension tubes) you put on the back of the lens. Also it does not record the RAW processing corrections and manipulations. Some people are quite happy to look at fake autumnal photo without realizing that the photo was taken in the summer...

teplit commented 4 years ago

The problematic ProPhoto profile is attached here. I got it from %SystemRoot%\System32\spool\drivers\color . I don't know which application put it there (most likely Adobe Photoshop).

In order to reproduce the problem you need to place this profile in the color profiles directory specified in RawTherapee Preferences ► Color Management. Then you may need to restart RawTherapee for the change to take effect.

The problem manifests on Windows 10 machines (real and virtual), but not on Linux (at least not on my OpenSUSE virtual machine).

RawTherapee 5.8 ships with several output profiles. Unfortunately they are not documented well in RawPedia - for example RTv4_Large and RTv4_Wide are not documented. Also there is no explanation for the differences between v2 and v4 profiles.

Thanatomanic commented 4 years ago

So, just to comment: I think that when an output file of 0 bytes is produced, this is a bug and should be considered a failed export. As mentioned by @teplit embedded profiles in exported png's are possible and should be possible according to the spec. Now the only thing is how to find the bug :-)

@teplit The ProPhoto profile you mention is a default profile that comes with Windows (afaik).