Page 1 of 1

TIF to PNG to TIF is not the same input as output

Posted: 2015-05-04T03:22:47-07:00
by jaffamuffin
Hi All

What I expect to be able to do is store an uncompressed TIF as a losslessly compressed PNG, and be able to convert the PNG back to TIF and have the same image as before. But it doesn't seem to be the case. Can anyone explain what is happening and how I may achieve my goal ? Thanks

Code: Select all

W:\png_tif>convert 000025_orig.tif 25.png
W:\png_tif>convert 25.png -strip 25_png_strip.tif
W:\png_tif>convert 000025_orig.tif -strip 25_tif_strip.tif

W:\png_tif>md5sums 25_tif_strip.tif
25_tif_strip.tif                                     3755906e7bed98db95ccc0106e461b6c

W:\png_tif>md5sums 25_png_strip.tif
25_png_strip.tif                               924c9de42959ebefc7b61ba75f848ee0

W:\png_tif>compare 25_tif_strip.tif 25_png_strip.tif diff.png
The source image is a scanned page of Text in 8bpp gray.
The last command a compare shows a feint version of the page, like someone upped the brightness of the original scan, which shows that the image data is different, and not just the file data.

Any thoughts ?

im version Version: ImageMagick 6.9.1-2 Q8 x64 2015-04-14 http://www.imagemagick.org Win 7

Re: TIF to PNG to TIF is not the same input as output

Posted: 2015-05-04T09:23:59-07:00
by fmw42
try adding -compress none when converting a tiff.

Re: TIF to PNG to TIF is not the same input as output

Posted: 2015-05-04T16:09:43-07:00
by snibgo
md5sums will find differences in metadata as well as the image.

Please put 000025_orig.tif somewhere like dropbox.com and paste the URL here.

Re: TIF to PNG to TIF is not the same input as output

Posted: 2015-05-04T20:09:27-07:00
by glennrp
snibgo wrote:md5sums will find differences in metadata as well as the image.
Right. Use

Code: Select all

 identify -verbose file.tif | grep ignature
to find out if the image data is the same. But OP said the result was lighter, which sounds to me like a problem with RGB (linear) versus sRGB (gamma) colorspace. I don't think "-compress none" is likely to help.

Re: TIF to PNG to TIF is not the same input as output

Posted: 2015-05-04T20:58:17-07:00
by snibgo
Yes. A possible cause is 000025_orig.tif isn't sRGB and contains correct metadata, so converting to sRGB 25.png works fine, and converting that to 25_png_strip.tif also works fine. But reading 000025_orig.tif them immediately "-strip" removes the metadata, so it won't get converted to sRGB correctly.

But that's just a guess. We need to see the file 000025_orig.tif.

Re: TIF to PNG to TIF is not the same input as output

Posted: 2015-05-19T06:58:47-07:00
by jaffamuffin
https://www.dropbox.com/sh/p0gjpa7k5x7t ... GdyZa?dl=0

Hi Guys Thanks for your replies. See the above dropbox link for the files. Interesting about the RGB data, I haven't yet had a chance to test any further yet, but the files are there if you want to have a look.

The idea was to be able to store TIF images in a more efficient way, but still be able to veiw/work with them etc and restore them to the original TIF if required. Is converting to PNG a reasonable approach to this ? An added benefit is web browsers can view png natively which does come in handy.

Re: TIF to PNG to TIF is not the same input as output

Posted: 2015-05-19T12:11:39-07:00
by snibgo
jaffamuffin wrote:The last command a compare shows a feint version of the page, like someone upped the brightness of the original scan, which shows that the image data is different, and not just the file data.
The output image of "compare" shows differences in red, over a very grayed version. You are seeing the very grayed version.

It may be easier to use a specific metric:

Code: Select all

f:\web\im\samples2>%IM%compare -metric AE 25_tif_strip.tif 25_png_strip.tif d.png
0
How many pixels are different? Zero.

Aside: tiff files can be compressed in various ways, if you want. I generally use "-compress Zip".