Rawtherapee Output PNG enormous


(Kodiak Firesmith) #1

Hello! I’ve googled around a bit and read the docs on image saving, but I’m not finding an answer for why an exported 16bit PNG file from a 24MB RAW image would end up being 120MB. I didn’t expect it to be so much larger than the RAW file it came from. I am quite new and basically took a RAW image and did exactly what the “Getting Started - Basic” page lays out w/r/t basic corrections and processing, then exported to 16bit PNG highest quality. For comparison I also exported (without any retouching) from Shotwell, the same picture, and got a 30MB file - larger than the RAW, but not enormous.

Are PNG file sizes expected to be so large?

Details: Sony a6000DSC02220-retouch.png.out.pp3 (10.2 KB)


#2

Raw file has 12 or 14 bits per grayscale pixel, whereas demosaiced colour image will have 16x3=48 (or 64 if there is alpha channel) bits per colour pixel. That’s why a saved losslessly compressed TIFF or PNG file is usually larger than the original raw file.


(Chaotic Sys) #3

24M=6,000*4,000

(6,000*4,000) * 16 * 3 = 1,152,000,000 bits = 144,000,000 bites = 137.3 MB

I created a picture of the same size in the GIMP, and then saved it in uncompressed 16-bit TIFF and PNG. And all the files were about 137MB.


(Elle Stone) #4

@panomies and @Chaotic_Sys already gave the theoretical file sizes for uncompressed 3-channel RGB image files saved at 16-bit integer precision. I have a Sony A7 camera, which saves 6000 by 4000 pixel raw files, which before interpolation are roughly 24Mib. A sample raw file exported as an uncompressed png from RT was 138MiB, and the compressed png was 105.3Mib. Opening the uncompressed png with GIMP-2.9 and saving it to disk using maximum compression produced a 105.3Mib file, same size as the RT-compressed png.

Uncompressed interpolated image file sizes as saved to disk by a raw processor are completely independent of the file size of the original raw file saved by the camera. The real mystery isn’t why RT pngs are so large, but why the Sony raw files are so small. As amply documented on the internet (https://www.dpreview.com/articles/2834066212/the-raw-and-the-cooked-pulling-apart-sony-raw-compression is a good place to start), Sony “lossy compresses” the raw files for A7 cameras and presumably does the same thing with your A6000. Looking at some numbers:

Nominally the A7 and I’m guessing also your A6000 are 14-bit cameras. So in theory the raw files should be roughly 40.1 megabytes in size:

4000px high times 6000px wide = 24000000 pixels
Times 14 bits per pixel = 336000000 bits
Divided by 8 bits per byte = 42000000 bytes
Divided by 1048576 bytes per megabyte = 40.1 megabytes, not counting exif data and any thumbnails.

In reality the Sony raw files are “lossy compressed” (information is permanently lost) using a two-stage compression algorithm. The first stage reduced the nominally 14-bit capture to 11 bits. If this were the only compression, then the resulting raw files should be roughly:

4000px high times 6000px wide = 24000000 pixels.
Times 11 bits per pixel = 33000000 bits.
Divided by 8 bits per byte = 1048576 bytes.
Divided by 1048576 bytes per megabyte = 31.5 megabytes.

Sony’s “second stage” compression takes the file size all the way down to 24 megabytes, which is slightly less than the amount of space it would take to store an uncompressed raw file saved by a 9-bit camera. Remember, this is lossy compression all the way, lossy compression to 11-bits of information per pixel, and then further lossy compression down to somewhat less than 9 bits of information per pixel.

Here is a nice link which explains the various “bits to bytes to megabytes” calculations:


(Kodiak Firesmith) #5

Thanks so much @panomies, @Chaotic_Sys, and Elle! I had no idea it would be standard to “blow up” the size of the file so much. Is there a common best practice for stepping down the resultant images in the least destructive way for the following use-cases?

  • Long-term cloud storage: Flickr, 500px, Google Photos
  • Social media, eg Facebook

I’m guessing the common practice would be to export to 8 bit jpeg? For long-term local storage I suppose I’d probably leave most of the files as .ARW on-disk, with the accompanying .pp3 file to be able to see them retouched.

Thanks again all for taking the time to explain the reasons behind the file sizes.


(Kodiak Firesmith) #6

Also @Elle - sorry it only let’s me respond to 2 usernames at a time as I’m a new user.


#7

JPEG is the most shareable file type partly because of its small footprint. In fact, you should be able to get away with 90+ quality without perceptible degradation. Caution: the quality value is different for every app, so the 92 for GIMP is different from the 92 for Photoshop. Some sites like this forum are able to convert the file to the specs they prefer. Some apply heavy compression that degrade the image; in that case, I generally feed them the best I can and let the degradation and re-scaling happen on their end.

Yes, that is what I do myself except I don’t even keep the sidecars. It is also entirely possible to compress the files to save even more space.


#8

@Kodiak_Firesmith I edited my post slightly. If you have any more questions, ask away. BTW, welcome to the forum!