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

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
jogco
Posts: 6
Joined: 2015-04-03T11:50:38-07:00
Authentication code: 6789

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

Post 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
Last edited by jogco on 2015-04-10T12:02:29-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

What should the image look like?

For me, IM v6.9.1-0 on Windows 8.1, the result is mostly light.
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: convert produces distorted TIFF file (ImageMagick ImageMagick-6.9.1-0)

Post 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?
jogco
Posts: 6
Joined: 2015-04-03T11:50:38-07:00
Authentication code: 6789

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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?
jogco
Posts: 6
Joined: 2015-04-03T11:50:38-07:00
Authentication code: 6789

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

Post 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.
jogco
Posts: 6
Joined: 2015-04-03T11:50:38-07:00
Authentication code: 6789

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

Post by jogco »

Here is another example.

Input:
Image


Output:
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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?
snibgo's IM pages: im.snibgo.com
jogco
Posts: 6
Joined: 2015-04-03T11:50:38-07:00
Authentication code: 6789

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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?
jogco
Posts: 6
Joined: 2015-04-03T11:50:38-07:00
Authentication code: 6789

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

Post 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
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

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

Post by dlemstra »

Thanks for coming back to the forum, this will be helpful for someone who will find this post in the future.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply