Odd behavior with "-smush" in IM 7.0.7-0

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
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Odd behavior with "-smush" in IM 7.0.7-0

Post by GeeMack »

Using ImageMagick 7.0.7-0 Q16 x64 HDRI (or ImageMagick 6.9.8-10 Q16 x64 HDRI) on Windows 10. When I run this command...

Code: Select all

magick -background none -bordercolor none -size 50x50 ^
   xc:red xc:orange xc:yellow xc:none xc:green xc:blue xc:purple +smush 0 smushtest1.png
I get this result...

Image

Apparently the "+smush" operation is pushing the green square over the transparent square and almost entirely covers the yellow, too. Only a single pixel wide column of yellow remains.

By adding a transparent border to each square, the results are similar, but it even pushes the green over that last one pixel column of yellow...

Code: Select all

magick -background none -bordercolor none ^
   -size 50x50 xc:red xc:orange xc:yellow xc:none xc:green xc:blue xc:purple ^
   -border 10 +smush 0 smushtest2.png
Image

This will occur when appending horizontally or vertically with either "+smush" or "-smush".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Odd behavior with "-smush" in IM 7.0.7-0

Post by fmw42 »

I can confirm on IM 6.9.9.12 and IM 7.0.6.0 Q16 Mac OSX. Neither persevere the full width of the transparent square even when adding -alpha on -channel rgba.

Code: Select all

magick -size 50x50 xc:red xc:orange xc:yellow xc:none xc:green xc:blue xc:purple -alpha on -channel rgba -background none +smush 0 smushtest1.png
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Odd behavior with "-smush" in IM 7.0.7-0

Post by magick »

If an image has transparent pixels, the smush offset creates a negative offset, presumably so that images with a transparent background are smushed together. A fully transparent image creates a negative offset equal to the width of the transparent image. So smush is behaving as designed-- but not behaving the way you had hoped. For your use case, use -append instead.
Post Reply