Page 1 of 1

Converting 16 bit tiff to 16 bit png (greyscale)

Posted: 2008-04-21T05:04:18-07:00
by ndhb
Hi all.

I am trying to convert 16 bit greyscale tiff to 16 bit png with: "convert infile.tif -depth 16 outfile.png". This works correctly only the png file includes all three (RGB) channels (48 bit). Is it possible to write only one channel with IM or do I have to use another program?

Searching the forum I found this thread: http://redux.imagemagick.org/discourse- ... 16+bit+png for the same problem but without any solution. I have looked at the documentation and tried various approaches but without success.

I have installed ImageMagick 6.4.0 04/04/08 Q16 on Windows.

Thanks in advance,
Nicolai

Re: Converting 16 bit tiff to 16 bit png (greyscale)

Posted: 2008-04-21T10:09:20-07:00
by fmw42
Are you on a 16-bit version of IM? If so, try

convert infile.tif -depth 16 -type Grayscale outfile.png

I am not sure that -depth is needed if you are on a 16-bit IM? You could also try

convert infile.tif -type Grayscale outfile.png

If this does not work, first check that your tif file is truly grayscale (no differences in channel grayscale values). Verify using

convert infile.tif -verbose info:

and

convert outfile.png -verbose info:

If this is all true and you still cannot get a single channel output and you are sure PNG supports that kind of image, then report this to the Bugs forum

Re: Converting 16 bit tiff to 16 bit png (greyscale)

Posted: 2008-04-21T11:11:42-07:00
by ndhb
Thank you very much fmw42. It appears to work. I feel a bit dumb I didn't see that switch before :)

The images .tif and .png appears identical when checked with 'compare -metric ae infile.tif outfile.png diff.png' and 'identify -format %k%' reports the same number of unique pixels for the .tif and .png images.

I found out that -type Grayscale and -type Optimize produces the same result.

For some reason the .png image (1.441.440 bytes) is slightly larger than the .tif (1.212.944 bytes) with '-quality 100'. That part I don't quite understand as both are lossless and zip compressed.

Re: Converting 16 bit tiff to 16 bit png (greyscale)

Posted: 2008-04-21T11:25:40-07:00
by fmw42
With regard to the file sizes, I don't know the answer. You will have to asked the IM folks. The only thing I can think of is different amount of data in the headers. You could try adding -strip to strip the profiles and other header data and see if they both end up the same. But I suspect there are header data that cannot be stripped and each format has a different amount of header info.