Page 1 of 1
bordercolor and alpha-color colors inversed/wrong
Posted: 2017-02-09T06:29:51-07:00
by bsArithnea
Hi,
I am using this Imagemagick version
Code: Select all
Version: ImageMagick 7.0.3-8 Q16 x64 2016-11-24 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
first i "trim" the image (everything fine)
Code: Select all
convert someimage.tif -trim -resize 305x305 cropped.jpg
secondly i want to add a 10px white frame/border (the border is actually black/dark brown depending on the monitor)
Code: Select all
convert -alpha-color white -frame 10 cropped.jpg cropped_w_border.jpg
OR
Code: Select all
convert -bordercolor white -border 10 cropped_resized.jpg cropped_resized_with_border.jpg
OR
Code: Select all
convert -bordercolor #ffffff -border 10 cropped_resized.jpg cropped_resized_with_border.jpg
Instead, if i use one of the following commands, i get an perfectly white border, like i expected it from the other commands:
Code: Select all
convert -bordercolor #000000 -border 10 cropped_resized.jpg cropped_resized_with_border.jpg
Code: Select all
convert -bordercolor black -border 10 cropped_resized.jpg cropped_resized_with_border.jpg
If i use
Code: Select all
convert -bordercolor blue -border 10 cropped_resized.jpg cropped_resized_with_border.jpg
i get a yellow border
Re: bordercolor and alpha-color colors inversed/wrong
Posted: 2017-02-09T07:47:15-07:00
by snibgo
Is your input file CMYK?
Your commands are in the wrong order. You shouldn't add a "-border" to an image before you have read the image. The order should be: read the image, process it, write it.
After "-trim", you should generally have "+repage".
Re: bordercolor and alpha-color colors inversed/wrong
Posted: 2017-02-10T02:48:31-07:00
by bsArithnea
Hallo snibgo,
Identify tells me the image is an cmyk
Code: Select all
hpa00276.tif TIFF 1437x1437 1437x1437+0+0 8-bit CMYK 8.279MB 0.000u 0:00.000
Also the "cropped" image is CMYK
Code: Select all
cropped.jpg JPEG 189x305 189x305+0+0 8-bit CMYK 28.6KB 0.000u 0:00.000
i didnt realize that the order is so important. Thank you very much for the hint.
Yea i learned that RGB is additive and CMYK is subtractive. Based on your hint, that is the problem right?
I am trying to add a additive color to the subtractive CMYK. I thought that imagemagick will simply "convert" my "black" to the apropriate color space (RGB/CMYK).
The funny thing is.. i tried the same commands on Imagemagick 6.9.X.X on a linux machine and it worked perfectly. Hence i think (or thought) that there is a bug and for sure i used the same picture as in my initial post.
Code: Select all
[root@celum512 tmp]# identify hpa00276.tif
hpa00276.tif TIFF 1437x1437 1437x1437+0+0 8-bit CMYK 8.279MB 0.000u 0:00.000
[root@celum512 tmp]# identify hpa00276.tif
hpa00276.tif TIFF 1437x1437 1437x1437+0+0 8-bit CMYK 8.279MB 0.000u 0:00.000
[root@celum512 tmp]# convert hpa00276.tif -trim -resize 305x305 resized.jpg
[root@celum512 tmp]# convert resized.jpg -bordercolor white -border 5x5 resized_bordered.jpg
[root@celum512 tmp]# convert -version
Version: ImageMagick 6.9.2-10 Q16 x86_64 2016-04-15 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC OpenMP
Delegates (built-in): bzlib freetype gslib jng jpeg png ps tiff x zlib
Re: bordercolor and alpha-color colors inversed/wrong
Posted: 2017-02-10T03:46:44-07:00
by snibgo
In IM, colour names are actually synonyms for numbers. "Black" really means "#000" and "white" means "#fff". This is true (as far as I know) whatever the colorspace. In CMYK, "#000" means no ink so we get white paper. And "#fff" means full ink, so we get black.
And "red" is "#f00", but in CYMK we get cyan ink.
So, using colour names in CMYK gives you the opposite to using them in RGB.
As a rule of thumb, I suggest you never use colour names unless the image is RGB (which includes sRGB).
If you want a blue border whatever the colour space is, you can either:
(1) Test the image, and use #00f for RGB, #ff0 for CMYK, etc, or
(2) Create a blue image in sRGB, and convert that to the required colorspace, and composite the image over it, or
(3) Convert your image to sRGB, do your processing, and convert it back to CMYK at the end.
Re: bordercolor and alpha-color colors inversed/wrong
Posted: 2017-02-10T06:39:10-07:00
by bsArithnea
Hi snibgo,
thanks for you replay.
i am just wondering why the behavior is now worse in 7.X then in 6.9.
Because (as shown) "White" etc works perfectly fine under 6.9 in linux (didnt test 6.9 under windows)
But with 7.X it doesnt.
Best Regards
Re: bordercolor and alpha-color colors inversed/wrong
Posted: 2017-02-10T12:38:50-07:00
by snibgo
Some testing shows that what I wrote above, that Red means #f00 which in CMYK is cyan, is true for some uses of colornames but not others.
For example, where c.jpg is a 1x1 CMYK file:
Code: Select all
convert c.jpg -fill Red -colorize 100 txt:
... what I wrote is correct, for v6.6.2-4, 6.8.0-9, 6.9.0-0, and "magick" in v7.0.3-5.
However, this command:
Code: Select all
convert c.jpg -bordercolor Red -border 1 -crop 1x1+0+0 +repage txt:
... in the v6 versions gives a CMYK(0,100%,100%,0), which is red, but in the v7 version gives CMYK(100%,0,0,0) which is cyan.
So, the behaviour of v7 "-bordercolor" when using CMYK has changed to be consistent with how "-fill" works in both v6 and v7.