Page 1 of 1

convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0) SOLVED

Posted: 2015-04-03T12:05:31-07:00
by jogco
This TIFF file gets distorted when saved by "convert".

http://dropcanvas.com/qy8j0/2 (link is a zip file with the TIFF inside)

Example command line:
convert example.tiff tiff:2.tiff

File is produced with the scanner utility included in MacOSX.

Update:
This is on Ubuntu 14.04. TIFF-related package versions if thats relevant:
ii libtiff5:i386 4.0.3-7ubuntu0.2
ii libtiff5-dev:i386 4.0.3-7ubuntu0.2
ii libtiffxx5:i386 4.0.3-7ubuntu0.2

Update 2:
This is what the resulting image looks like:
Image

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0)

Posted: 2015-04-03T12:54:56-07:00
by snibgo
What should the image look like?

For me, IM v6.9.1-0 on Windows 8.1, the result is mostly light.

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0)

Posted: 2015-04-03T14:22:44-07:00
by fmw42
Works fine for me under IM 6.9.1.0 Q16 Mac OSX. Looks mostly white. My libtiff is 4.0.3. Perhaps it is an endian issue on your system. See http://www.imagemagick.org/script/comma ... php#define for tiff:endian or tiff:fill-order?

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0)

Posted: 2015-04-04T12:00:09-07:00
by jogco
Thanks for the suggestion. I tried these combinations:

convert -define tiff:endian=msb example.tiff out.tiff
convert -define tiff:endian=lsb example.tiff out.tiff
convert -define tiff:fill-order=msb example.tiff out.tiff
convert -define tiff:fill-order=lsb example.tiff out.tiff
convert -define tiff:endian=msb -define tiff:fill-order=msb example.tiff out.tiff
convert -define tiff:endian=lsb -define tiff:fill-order=lsb example.tiff out.tiff

Same result...

And for reference here is a zip with the distorted file I get and full version info:

http://dropcanvas.com/wwemj/1

$ convert -version
Version: ImageMagick 6.9.1-0 Q16 i686 2015-04-03 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: DPC OpenMP
Delegates (built-in): fontconfig freetype jbig jng jpeg lzma pangocairo png tiff webp x xml zlib

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0)

Posted: 2015-04-04T13:31:27-07:00
by fmw42
Is it possible you have more than one version of IM or libtiff? I do not get that dark result. It is mostly white. Does

type -a

or

which -a

entered in a terminal give you more than one IM?

What version of libtiff?

convert -list format

should show the version. Mine is LIBTIFF, Version 4.0.3

Do you get a different result with the -defines after the input image so that they apply to the output image?

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0)

Posted: 2015-04-05T02:51:54-07:00
by jogco
i'm using imagemagick compiled from source, so in reality the command line I use is something like
$ ImageMagick-6.9.1-0/utilities/convert infile.tiff outfile.tiff
(I have tried the version of convert that comes with ubuntu 14.04 as well (ImageMagick 6.7.7-10 2014-03-06 Q16), with exactly the same result)

Putting the define after the input file:

$ ImageMagick-6.9.1-0/utilities/convert example.tiff -define tiff:endian=msb -define tiff:fill-order=msb out-msb-msb.tiff
$ ImageMagick-6.9.1-0/utilities/convert example.tiff -define tiff:endian=lsb -define tiff:fill-order=lsb out-lsb-lsb.tiff
$ ImageMagick-6.9.1-0/utilities/convert example.tiff -define tiff:endian=lsb -define tiff:fill-order=msb out-lsb-msb.tiff
$ ImageMagick-6.9.1-0/utilities/convert example.tiff -define tiff:endian=msb -define tiff:fill-order=lsb out-msb-lsb.tiff

Same result.

TIFF version:

$ ImageMagick-6.9.1-0/utilities/convert -list format | grep -i tiff
EPT rw- Encapsulated PostScript with TIFF preview
EPT2 rw- Encapsulated PostScript Level II with TIFF preview
EPT3 rw+ Encapsulated PostScript Level III with TIFF preview
PTIF* rw+ Pyramid encoded TIFF
TIFF* rw+ Tagged Image File Format (LIBTIFF, Version 4.0.3)
TIFF64* rw- Tagged Image File Format (64-bit) (LIBTIFF, Version 4.0.3)

Btw, the result I expect is to get an image thats identical to the input image, ie mostly white. Like this:
Image.

Im trying to batch rotate around 500 tiff files and everyone I've tried so far gets distorted. :(
They are all produced by Mac OSX Image Capture.

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0)

Posted: 2015-04-05T05:30:19-07:00
by jogco
Here is another example.

Input:
Image


Output:
Image

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0)

Posted: 2015-04-05T06:06:51-07:00
by snibgo
Both those files are JPG. What command(s) did you use?

"-define tiff:endian=msb" shouldn't make any difference, as the source file example.tiff is 1 byte/pixel.

Does the same problem occur when reading or writing other file types such as PNG or JPG?

EDIT: Another factor is the profile in example.tiff. Does "-strip" make any difference?

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0)

Posted: 2015-04-05T11:10:54-07:00
by jogco
Here is the original: http://dropcanvas.com/96ols/1
And the output: http://dropcanvas.com/96ols/2

I tried the -strip option. No difference.

I can convert example2.tiff to png and the png looks as it should but if I convert it back to a tiff i get the usual result. So there is obviously something wrong with the ability to write tiff files in my version of ImageMagick/convert. I have also tried various other image files now. What I have found so far is that converting from jpeg to tiff always works, but converting from tiff to tiff or from png to tiff never works... If png to tiff had worked I could have used png as a intermediate format in my batch processing. I dont want to lose quality by using jpeg.

I guess the next step is removing both libtiff and imagemagick completely from the system and installing both from source, latest versions, and see what I get. This is crazy.

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0)

Posted: 2015-04-05T13:05:10-07:00
by fmw42

Code: Select all

Btw, the result I expect is to get an image thats identical to the input image, ie mostly white. Like this:
That is what it looks like when I do the convert

Code: Select all

convert original.tiff result.tiff
no other arguments.

Have you added any lines to your delegates.xml file for tiff such that you change black to white?

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0) SOLVED

Posted: 2015-04-10T12:01:10-07:00
by jogco
Apparently it was some kind of issue in libtiff 4.0.3-7ubuntu0.2 that is solved in 4.0.3-7ubuntu0.3

Re: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0) SOLVED

Posted: 2015-04-10T12:22:26-07:00
by dlemstra
Thanks for coming back to the forum, this will be helpful for someone who will find this post in the future.