-border switch changes colors of whole image

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
HugoRune
Posts: 90
Joined: 2009-03-11T02:45:12-07:00
Authentication code: 8675309

-border switch changes colors of whole image

Post by HugoRune »

When operating on an image sequence, and adding a border to the last image of the sequence, the -border switch randomly changes colors of that image, if certain preconditions are met.

Strongly simplified example:

convert logo: ( -clone 0 -bordercolor green -border 10x10 ) +append test.png
Image This is the expected result.


As far as i understand, the operation
( +clone +clone -compose subtract -composite +delete )
may be pointless, but should not change the result.
The last image in the stack is cloned twice, both copies are combined in one composite, and this composite is deleted, resulting in no new image on the stack

However:
convert logo: ( +clone +clone -compose subtract -composite +delete ) ( -clone 0 -bordercolor green -border 10x10 ) +append test.png
Image Why do the colors change?


The exact result depends on the last -compose operation:
convert logo: ( +clone +clone -compose multiply -composite +delete ) ( -clone 0 -bordercolor green -border 10x10 ) +append test.png
Image


Update: -respect-parenthesis prevents this weird behaviour, so I am not sure if it is a bug after all.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -border switch changes colors of whole image

Post by fmw42 »

Removed as information was miss-leading and in this case, invalid

Applogies to Fred Weinhaus -- Anthony
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: -border switch changes colors of whole image

Post by anthony »

Border itself works by composition. That is it creates a new image of the right size for the additional borders, then composes the original image over the new one. This assumes that the original image uses an 'Over' composition method.

Essentually you set a -compose subtract which is then used by the -border to produce weird results. Add a -compose Over or a -compose Copy BEFORE the -boder option.

NOTE You generally can not use -respect-parenthesis to prevent this 'compose method' setting 'leaking from one parenthesis to another, as it also gets stored into the images meta-data. Though in this case as you actually delete the image, the -respect-parenthesis may actually work.

Better to just reset the setting when you are finished with it.

See IM Examples Border for more info
http://www.imagemagick.org/Usage/crop/#border

As for the reasons why the border usage is not internally fixed to either 'Over' or 'Copy' see the discussion that was saved in
Border, Frame, and the use of BorderColor
http://www.imagemagick.org/Usage/misc/#border
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply