Bugged conversion from .tif to .png

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
pneumatic
Posts: 9
Joined: 2017-08-25T21:35:10-07:00
Authentication code: 1151

Bugged conversion from .tif to .png

Post by pneumatic »

When converting this .tif to a .png using

Code: Select all

convert CFX_lut.tif CFX_lut.png
, imagemagick mysteriously generates two .png files, neither of which are anything close to the original file in terms of their pixel values.

I suspect this has something to do with the dimensions being only 256x1 pixel. This can't be avoided as the image functions as an 8-bit lut for color correction purposes. In the meantime I am using tiff2png.exe , but I like ImageMagick and would prefer to use it for all of my image processing needs.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Bugged conversion from .tif to .png

Post by fmw42 »

Your tiff file has two pages or layers. Not sure which. But the second one is totally white. How did you create it?

Anyway try

Code: Select all

convert CFX_lut.tif[0] CFX_lut.png
or

Code: Select all

convert CFX_lut.tif[0] -alpha off CFX_lut.png

Does that work?

The results are identical for me on IM 6.9.9.9 Q16 Mac OSX

compare -metric rmse CFX_lut.tif[0] CFX_lut.png null:
0 (0)

Please always provide your IM version and platform when asking questions on this forum. Syntax may differ.
pneumatic
Posts: 9
Joined: 2017-08-25T21:35:10-07:00
Authentication code: 1151

Re: Bugged conversion from .tif to .png

Post by pneumatic »

fmw42 wrote: 2017-08-25T22:11:03-07:00 Your tiff file has two pages or layers. Not sure which. But the second one is totally white. How did you create it?
You are right there are two layers in there which I had forgotten about. The first layer (all white pixels) should not be needed anyway, I suspect it was just used to create the ramp (I am not the original author of the file - it was provided by Florian Höch , author of DisplayCAL).

fmw42 wrote: 2017-08-25T22:11:03-07:00 Anyway try

Code: Select all

convert CFX_lut.tif[0] CFX_lut.png
or

Code: Select all

convert CFX_lut.tif[0] -alpha off CFX_lut.png
Does that work?
Unfortunately not; the pixel values are all out. eg. pixel at coordinate x128 y1 should have an RGB value of 128,128,128 but its value is 149,149,149.
fmw42 wrote: 2017-08-25T22:11:03-07:00 The results are identical for me on IM 6.9.9.9 Q16 Mac OSX
compare -metric rmse CFX_lut.tif[0] CFX_lut.png null:
0 (0)
For me:
compare -metric rmse CFX_lut.tif[0] CFX_lut.png
24015.5 (0.366453)

fmw42 wrote: 2017-08-25T22:11:03-07:00 Please always provide your IM version and platform when asking questions on this forum. Syntax may differ.
Sorry,
ImageMagick-7.0.6-9-portable-Q16-x86.zip
ImageMagick-7.0.6-9-portable-Q16-x64.zip
Last edited by pneumatic on 2017-08-25T22:56:17-07:00, edited 1 time in total.
pneumatic
Posts: 9
Joined: 2017-08-25T21:35:10-07:00
Authentication code: 1151

Re: Bugged conversion from .tif to .png

Post by pneumatic »

Forgot to mention, even if remove the second layer (white pixels) from the .tif, convert still produces wrong values.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Bugged conversion from .tif to .png

Post by fmw42 »

In IM 7.0.6.9 Q16 Mac OSX, I still get:

magick CFX_lut.tif[0] -alpha off CFX_lut.png
magick compare -metric rmse CFX_lut.tif[0] CFX_lut.png null:
0 (0)

So the input values are the same as the output values.

In the input, I get 128 at x,y=28,0. Same for the output. Indices in IM start at 0

Did you try my commands? Do you 0 for compare. How are you measuring your pixel values?
pneumatic
Posts: 9
Joined: 2017-08-25T21:35:10-07:00
Authentication code: 1151

Re: Bugged conversion from .tif to .png

Post by pneumatic »

fmw42 wrote: 2017-08-25T23:43:05-07:00 Did you try my commands? Do you 0 for compare.
Yes. Did you not see my last message?
fmw42 wrote: 2017-08-25T23:43:05-07:00 How are you measuring your pixel values?
With compare.exe like you suggested and in photoshop with the ruler set to pixels.

So it looks like the Mac OSX version is fine but Windows version has a bug. Maybe someone else with the Windows version could test to confirm...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Bugged conversion from .tif to .png

Post by snibgo »

IM v6.9.5-3 on Windows 8.1:

Code: Select all

f:\web\im>%IM%convert CFX_lut.tif[0] x.png

f:\web\im>%IM%compare -metric RMSE CFX_lut.tif[0] x.png NULL:
17134.6 (0.261457)
The tif has an alpha channel, but it is unassociated. Some versions of IM don't deal with this consistently. A workaround is "-channel RGB":

Code: Select all

f:\web\im>%IM%compare -channel RGB -metric RMSE CFX_lut.tif[0] x.png NULL:
0 (0)
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Bugged conversion from .tif to .png

Post by fmw42 »

One could also remove the alpha channel using -alpha off

Code: Select all

magick CFX_lut.tif[0] -alpha off CFX_lut.png
magick compare -metric rmse \( CFX_lut.tif[0] -alpha off \) CFX_lut.png null:
0 (0)
Post Reply