2
\$\begingroup\$

I have 16-bit depth TIFF images that I want to convert to HEIF files with 14-bit depth (because they are processed photos created from camera bodies with a 14-bit sensor). The command I run is:

$ convert 20240524-1093.tif[0] -depth 14 -quality 90 heif:- > 20240524-1093@90%.heif

(I use heif:- and redirect because I want to preserve extended attributes in case the target file already exists).

But the generated files have 12-bit depth:

$ identify 20240524-1093*
20240524-1093.tif[0] TIFF 5189x3459 5189x3459+0+0 16-bit sRGB 94.5797MiB 0.000u 0:00.002
20240524-1093.tif[1] TIFF 160x107 160x107+0+0 8-bit sRGB 0.000u 0:00.000
20240524-1093@90%.heif HEIF 5189x3459 5189x3459+0+0 12-bit sRGB 11.1723MiB 0.110u 0:00.114

What am I doing wrong?

The version is:

$ convert --version
Version: ImageMagick 7.1.1-31 Q16-HDRI x86_64 46db807b1:20240421 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(5.0) 
Delegates (built-in): fontconfig freetype heic jbig jng jpeg jxl lcms lzma png tiff webp x xml zlib
Compiler: gcc (4.2)
\$\endgroup\$
1
  • \$\begingroup\$ Have you try to exec command with magick, not with convert? \$\endgroup\$ Commented May 27 at 12:03

1 Answer 1

2
\$\begingroup\$

You are probably not giving it 14 bit data. Just because the camera has/uses a 14 bit ADC does not mean the sensor is necessarily generating 14 bit data. In fact, it usually will not be (higher ISO's, etc).

For example, this is the Nikon Z9 which only uses a 14 bit ADC. This is the data bit depth that is reasonably distinguishable from noise (DXO calls it tonal range).

enter image description here

This is the total data bit depth at various ISO's including noise ("engineering dynamic range")... it requires 1 bit per EV for a raw file, so at most the sensor generates 13 bit. Which makes sense, the ADC needs to be capable of processing at least the max generated... in this case a 12 bit ADC would be inadequate.

enter image description here

And this is the bit depth of the color information generated. Even at it's highest it is less than 8 bit per pixel/channel (24 bit combined).

enter image description here

And in all cases, the bit depth decreases as ISO is increased, because the actual exposure decreases. Photons (light) = electrons = data... The 14 bit ADC cannot increase the data/accuracy, just as writing it into a 16 bit raw container file doesn't.

The heif format is a 16 bit container much like tiff and raw files are, but that doesn't mean it contains 16 bit data... it can't if it was written with a 14 bit ADC, or if the sensor generated even less.

As I understand it, imagemagick reports the actual bit depth recorded within the file. There is a way to generate a report that also shows the container/file depth... it will look like 16/12, 16/10 etc. The only way it will report 16/14 is if you gave it at least 14 bit (actual) to start with.

The GitHub ImageMagic discussions area is probably your best resource for more information.

\$\endgroup\$
9
  • \$\begingroup\$ Thanks for the hint. Actually I'm sure the original RAW is 14-bit, but I didn't check the TIFF that is generated by another application. I'll go and check. \$\endgroup\$ Commented May 27 at 16:08
  • \$\begingroup\$ How are you sure the original contains 14bit data? What camera? \$\endgroup\$ Commented May 27 at 19:08
  • \$\begingroup\$ It's a Sony a6700 and it's capable of 14-bits. But actually I've bought it a few days ago, so I'm still getting into acquaintance with it. The current settings (e.g. compressed RAW + burst) might reduce the depth to 12. Going to check. Exiftool says the RAW is 14 bits, but that it's just the metadata. \$\endgroup\$ Commented May 27 at 20:41
  • \$\begingroup\$ [Previous comment deleted because unclear] \$\endgroup\$ Commented May 27 at 21:05
  • \$\begingroup\$ Actually the deleted comment was irrelevant. According to this document from Sony, the a6700 produces 14 bits per sample when "Lossless compressed RAW" is used, which is my setting: sony.com/electronics/support/articles/00229990 — Indeed exiftool reports 14 bits per sample in the ARW: exiftool 20240524-1093.ARW | grep "Bits Per Sample" returns Bits Per Sample: 14. \$\endgroup\$ Commented May 27 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.