Possible bug with bilevel TIFF in IM 6.9.2.8 Q16 Mac OSX

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

Possible bug with bilevel TIFF in IM 6.9.2.8 Q16 Mac OSX

Post by fmw42 »

.
See viewtopic.php?f=1&t=28809&p=128236#p128233 for input images.

The following fails using 2.tif as input because it is bilevel and forces the output to be bilevel including where the color overlay image, label1.gif, is placed. I have tried adding -set colorspace sRGB, -colorspace sRGB and -type truecolor right after the input images. (The latter makes the resulting image totally black)

Code: Select all

convert 2.tif label1.gif -gravity northwest -geometry +3+3 \
-define compose:args=80,100 -compose dissolve -composite 2_label1a.tif
http://www.fmwconcepts.com/misc_tests/t ... abel1a.tif


But it works fine if one converts the 2.tif to PNG

Code: Select all

convert 2.tif 2.png
convert 2.png label1.gif -gravity northwest -geometry +3+3 \
-define compose:args=80,100 -compose dissolve -composite 2_label1b.tif
http://www.fmwconcepts.com/misc_tests/t ... abel1b.tif

Note that

Code: Select all

convert 2.tif -type truecolor -auto-level 2b.tif
results in a totally black image.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Possible bug with bilevel TIFF in IM 6.9.2.8 Q16 Mac OSX

Post by magick »

Add -depth 8 -compress zip to your command line. The TIFF image has a depth of 1 and a compression of Group4Compression. That is carried forward to the output image. The depth and compress options override these settings to produce the image you expect.
  • convert 2.tif label1.gif -gravity northwest -geometry +3+3 -define compose:args=80,100 -compose dissolve \
    -composite -depth 8 -compress zip 2_label1b.tif
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug with bilevel TIFF in IM 6.9.2.8 Q16 Mac OSX

Post by fmw42 »

Thanks that works.

I forgot about depth and compression when trying to override the bilevel input format.
mr_hunter
Posts: 16
Joined: 2015-12-09T08:45:47-07:00
Authentication code: 1151

Re: [RESOLVED] Possible bug with bilevel TIFF in IM 6.9.2.8 Q16 Mac OSX

Post by mr_hunter »

Hi there - This solution doesn't work for multi-page TIFFs as it just layers all the pages on top of each other and seems to not add the label. Any ideas? I've tried adding +adjoin but didn't make any difference.. :(
mr_hunter
Posts: 16
Joined: 2015-12-09T08:45:47-07:00
Authentication code: 1151

Re: [RESOLVED] Possible bug with bilevel TIFF in IM 6.9.2.8 Q16 Mac OSX

Post by mr_hunter »

I've tried with PDFs and it does the same sadly as I have a need to stamp PDFs with the label also.

If I don't hear from you before have an excellent Christmas (if you celebrate it).. :-)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug with bilevel TIFF in IM 6.9.2.8 Q16 Mac OSX

Post by fmw42 »

Can you provide an example multi-layer tiff for us to test?
mr_hunter
Posts: 16
Joined: 2015-12-09T08:45:47-07:00
Authentication code: 1151

Re: Possible bug with bilevel TIFF in IM 6.9.2.8 Q16 Mac OSX

Post by mr_hunter »

Hi there - sorry for delay. Wasn't on laptop over Christmas.

Here is the code and the associated files below...

convert 2.tif stampOnDoc.gif -gravity northwest -geometry +3+3 -define compose:args=80,100 -compose dissolve ^
-composite +adjoin -depth 8 -compress zip tmp2.tif

2.tif https://www.dropbox.com/s/b8y7shdrutcvag5/2.tif?dl=0
stampOnDoc.gif https://www.dropbox.com/s/hssmnifq2fiea ... c.gif?dl=0
tmp2.tif https://www.dropbox.com/s/jb33ac9h705zufc/tmp2.tif?dl=0

Thanks :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug with bilevel TIFF in IM 6.9.2.8 Q16 Mac OSX

Post by fmw42 »

-composite only works with two images. Your tiff has several layers which are considered by IM as separate input images. So you need to use -layers composite as follows setting the alpha channel of the overlay (gif) image to 80% or whatever you want.

Code: Select all

convert 2.tif -coalesce \
null: \
\( stampOnDoc.gif -alpha on -channel alpha -evaluate set 80% +channel \) \
-channel rgba -gravity northwest -geometry +3+3 \
-layers composite -depth 8 -compress zip result.tif
or

Code: Select all

convert 2.tif -coalesce \
null: \
\( stampOnDoc.gif -alpha on -channel alpha -evaluate set 80% +channel \) \
-channel rgba -gravity northwest -geometry +3+3 \
-layers composite -depth 8 -compress zip +adjoin result.tif
Post Reply