Page 1 of 1

Bugged conversion from .tif to .png

Posted: 2017-08-25T21:52:04-07:00
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.

Re: Bugged conversion from .tif to .png

Posted: 2017-08-25T22:11:03-07:00
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.

Re: Bugged conversion from .tif to .png

Posted: 2017-08-25T22:42:48-07:00
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

Re: Bugged conversion from .tif to .png

Posted: 2017-08-25T22:50:10-07:00
by pneumatic
Forgot to mention, even if remove the second layer (white pixels) from the .tif, convert still produces wrong values.

Re: Bugged conversion from .tif to .png

Posted: 2017-08-25T23:43:05-07:00
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?

Re: Bugged conversion from .tif to .png

Posted: 2017-08-26T01:01:49-07:00
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...

Re: Bugged conversion from .tif to .png

Posted: 2017-08-26T10:07:54-07:00
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)

Re: Bugged conversion from .tif to .png

Posted: 2017-08-26T10:13:14-07:00
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)