possible bug with -bordercolor
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
possible bug with -bordercolor
IM 6.6.1-10 Q16 Mac OSX Tiger
Is it possible to put a non-transparent border around a transparent image (without appending)?
These do not seem to work as the whole transparent area become red rather than just the border.
convert logo: -resize 50% -transparent white -bordercolor red -border 10 tmp.png
convert logo: -resize 50% -transparent white -channel rgba -background none -bordercolor "rgba(255,0,0,1)" -border 10 tmp.png
Am I misunderstanding how -border works with transparent images or is this a bug?
Is it possible to put a non-transparent border around a transparent image (without appending)?
These do not seem to work as the whole transparent area become red rather than just the border.
convert logo: -resize 50% -transparent white -bordercolor red -border 10 tmp.png
convert logo: -resize 50% -transparent white -channel rgba -background none -bordercolor "rgba(255,0,0,1)" -border 10 tmp.png
Am I misunderstanding how -border works with transparent images or is this a bug?
Re: possible bug with -bordercolor
Add -compose copy to your command line.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug with -bordercolor
thanks. yes this works.
convert logo: -resize 50% -transparent white -compose copy -bordercolor red -border 10 tmp.png
I had tried resetting -compose over rather than -compose copy.
convert logo: -resize 50% -transparent white -compose copy -bordercolor red -border 10 tmp.png
I had tried resetting -compose over rather than -compose copy.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug with -bordercolor
See IM Examples Border
http://www.imagemagick.org/Usage/crop/#border
The same problem is also in Frame, Extent, and the layer methods Flatten, Mosaic and Merge,
for the same reasons. A background image is created and the operator then composes the image onto the background. -compose copy means copy the transparent pixels too!
http://www.imagemagick.org/Usage/crop/#border
The same problem is also in Frame, Extent, and the layer methods Flatten, Mosaic and Merge,
for the same reasons. A background image is created and the operator then composes the image onto the background. -compose copy means copy the transparent pixels too!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug with -bordercolor
adding -compose copy does not work in montage
convert logo: -resize 50% -transparent white logo2t.png
montage -texture pattern:checkerboard \
logo2t.png logo2t.png logo2t.png logo2t.png \
-compose copy -bordercolor red -border 10 \
-geometry +10+10 -tile 2x2 logo2t_montage1.png
transparency is turned to white and not checkerboard
nor does
montage -texture pattern:checkerboard \
\( logo2t.png -compose copy -bordercolor red -border 10 \) \
\( logo2t.png -compose copy -bordercolor red -border 10 \) \
\( logo2t.png -compose copy -bordercolor red -border 10 \) \
\( logo2t.png -compose copy -bordercolor red -border 10 \) \
-geometry +10+10 -tile 2x2 logo2t_montage2.png
The following almost does what I want, but the first image has a gray border and not red.
montage -background none \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
-geometry +10+10 -tile 2x2 logo2t_montage3.png
How can I modify this last one to get the red border on the first image?
convert logo: -resize 50% -transparent white logo2t.png
montage -texture pattern:checkerboard \
logo2t.png logo2t.png logo2t.png logo2t.png \
-compose copy -bordercolor red -border 10 \
-geometry +10+10 -tile 2x2 logo2t_montage1.png
transparency is turned to white and not checkerboard
nor does
montage -texture pattern:checkerboard \
\( logo2t.png -compose copy -bordercolor red -border 10 \) \
\( logo2t.png -compose copy -bordercolor red -border 10 \) \
\( logo2t.png -compose copy -bordercolor red -border 10 \) \
\( logo2t.png -compose copy -bordercolor red -border 10 \) \
-geometry +10+10 -tile 2x2 logo2t_montage2.png
The following almost does what I want, but the first image has a gray border and not red.
montage -background none \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
-geometry +10+10 -tile 2x2 logo2t_montage3.png
How can I modify this last one to get the red border on the first image?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug with -bordercolor
Actually it is worse that that!fmw42 wrote:adding -compose copy does not work in montage
-border is now a special montage setting!! Just like -frame and -tile. Its value is simple saved away for future use rather than acted on immediately. I am not certain when this changed though, sometime about IM v6.1.0
See Montage, Border Decoration
http://www.imagemagick.org/Usage/montage/#border
It was done so that border could be added AFTER images are resized. Something which I can understand. However it currently does not play nicely with the montage -frame setting, though both could conceivably work together (with a border being added before the frame).
This change caught me by surprise as well, as my gif_anim_montage script previously made use of -border within a montage. Essentially that script is a montage that displays virtual canvas information, such as used by GIF Animations and experimental segmentation output.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug with -bordercolor
Anthony,
Do you see a workaround for why the first image has a gray border and the rest are correctly red?
Fred
Do you see a workaround for why the first image has a gray border and the rest are correctly red?
Fred
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug with -bordercolor
As -border is only being cached and not applied.
For example. in montage you can set border color AFTER the '-border' setting
All roses had a red border!
As this is a new "montage setting" I can only see this as a bug in the montage handling of border.
My solution to my problem with -border was to pre-process images using convert rather than montage.
NOTE: you can also use -extent to add a border, but specify the final size rather than border with!
That is not a special montage option so will work fine!
Note I needed to reset the -background color as it is a montage setting!
Actually both -border and -bordercolor is also a montage setting!
You should not get two different border colors, unless something is wrong!
For example. in montage you can set border color AFTER the '-border' setting
Code: Select all
montage rose: rose: rose: rose: -border 20 -bordercolor red -geometry +10+10 show:
As this is a new "montage setting" I can only see this as a bug in the montage handling of border.
My solution to my problem with -border was to pre-process images using convert rather than montage.
NOTE: you can also use -extent to add a border, but specify the final size rather than border with!
That is not a special montage option so will work fine!
Code: Select all
montage -gravity center \
\( rose: -background red -extent 100x100 \) \
\( rose: -background blue -extent 100x100 \) \
\( rose: -background green -extent 100x100 \) \
\( rose: -background white -extent 100x100 \) \
-background None -geometry +10+10 show:
Actually both -border and -bordercolor is also a montage setting!
You should not get two different border colors, unless something is wrong!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug with -bordercolor
Interesting:
This does not work with -bordercolor in the parens as the first image gets a gray border as shown above:
montage \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
-background none -geometry +10+10 -tile 2x2 logo2t_montage3.png
But this does work with -extent and all four images have a red border:
montage \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -gravity center -background red -extent 340x260 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -gravity center -background red -extent 340x260 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -gravity center -background red -extent 340x260 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -gravity center -background red -extent 340x260 \) \
-background none -geometry +10+10 -tile 2x2 logo2t_montage4.png
AND I just found out that this also works to give each image a red border by placing -bordercolor out of the parens
montage -bordercolor red \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -border 10 \) \
-background none -geometry +10+10 -tile 2x2 logo2t_montage5.png
This does not work with -bordercolor in the parens as the first image gets a gray border as shown above:
montage \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -bordercolor red -border 10 \) \
-background none -geometry +10+10 -tile 2x2 logo2t_montage3.png
But this does work with -extent and all four images have a red border:
montage \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -gravity center -background red -extent 340x260 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -gravity center -background red -extent 340x260 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -gravity center -background red -extent 340x260 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -gravity center -background red -extent 340x260 \) \
-background none -geometry +10+10 -tile 2x2 logo2t_montage4.png
AND I just found out that this also works to give each image a red border by placing -bordercolor out of the parens
montage -bordercolor red \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -border 10 \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite -border 10 \) \
-background none -geometry +10+10 -tile 2x2 logo2t_montage5.png
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug with -bordercolor
I repeat yet again!!!
In "montage" -border is useless except as a final montage specific setting. In montage it is not an operator, and its argument is only saved for later use (just like -frame in montage).
Using it in parenthesis or anywhere but at the end is useless!!!!!
Removing them all but at the end as a final setting....
This works perfectly. I do not know why it is failing in parenthesis as -border is just a setiing.
NOTE the order of -border and -bordercolor does not matter, as in montage BOTH are just settings that are saved for later use.
Most likely explanation for the previous failing is that the parenthesis handler is designed for "convert" and nor "montage" where it has extra settings that are only used at the very end, and this is confusing things. It may be that it is applying -border in some instances as a operator, when in montage it is only a setting.
In "montage" -border is useless except as a final montage specific setting. In montage it is not an operator, and its argument is only saved for later use (just like -frame in montage).
Using it in parenthesis or anywhere but at the end is useless!!!!!
Removing them all but at the end as a final setting....
Code: Select all
montage \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite \) \
\( -size 320x240 pattern:checkerboard logo2t.png -compose over -composite \) \
-background none -geometry +10+10 -tile 2x2 \
-border 10 -bordercolor red logo2t_montage3.png
NOTE the order of -border and -bordercolor does not matter, as in montage BOTH are just settings that are saved for later use.
Most likely explanation for the previous failing is that the parenthesis handler is designed for "convert" and nor "montage" where it has extra settings that are only used at the very end, and this is confusing things. It may be that it is applying -border in some instances as a operator, when in montage it is only a setting.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: possible bug with -bordercolor
The montage -border option sets the border width for the montage layout manager. If we apply the border instead to each image, when the layout manager scales the image to present as a tile on the montage canvas we could get different sized borders. The solution of course is two different options but we can't change the meaning now since folks have depended on -border affecting the layout manager for years now. The solution is to use context. Since parenthesis are relatively new we could use -border outside parens as a montage layout manager setting and anything inside parens as the normal -border behavior.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: possible bug with -bordercolor
Not forgetting, of course, that parentheses can be nested.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug with -bordercolor
Thanks. It has taken a while to sink in as to what you meant.Anthony wrote:In "montage" -border is useless except as a final montage specific setting. In montage it is not an operator, and its argument is only saved for later use (just like -frame in montage).
Using it in parenthesis or anywhere but at the end is useless!!!!!