Specify 16 bit int per channel on save

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jules43
Posts: 11
Joined: 2015-09-01T06:14:31-07:00
Authentication code: 1151

Specify 16 bit int per channel on save

Post by jules43 »

When saving the results of an image magic operation to a tiff or png, is there a way to specify 16 bit int per channel output?

Thanks

Jules
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Specify 16 bit int per channel on save

Post by fmw42 »

You must have compiled your IM version as Q16 or Q32. Then just add -depth 16 before writing the output. But if you input image was 8-bits, you will still have 8-bits at the end but spreach of 16 -bit range. Perhaps you can explain what processing you are doing. If it resamples the image, then you would get more values.
jules43
Posts: 11
Joined: 2015-09-01T06:14:31-07:00
Authentication code: 1151

Re: Specify 16 bit int per channel on save

Post by jules43 »

Thanks, I hadn't been certain that IM would preserve the bit depth on save. I should have provided more detail.

I am reading a 16 bit per pixel loss-less PSD and after processing (if any) I need to save it as as 16 bits per pixel loss-less TIFF or PNG.

I am using the Q16 version of ImageMagick 7 - I may look at moving to Q32 bit if I hit any precision problems.

Having seen the -depth option it looks like I don't need to specify it as it will be preserved by default.

Reading the docs on -depth then to led me to the -define options for controlling specific image format and the -quality, -type and -compress options. The combination of all of these looks like it gives me all the control I need.

I also found the section on common formats which clarified a few remaining questions I had.

Thanks again for pointing me in the right direction.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Specify 16 bit int per channel on save

Post by fmw42 »

IM 7 in Q16 should properly preserver 16-bit images. Yes you will need the proper -defines and other optios for saving to TIFF and to PNG

Results will be non-negative 16-bit integers. If you need negatives and fractional values, then you need Q16 HDRI. But I don't think from what you said you need that accuracy. Q32 would also be integers only without HDRI.
Post Reply