'+level-colors black' and cmyk result

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

'+level-colors black' and cmyk result

Post by indiego »

The following code works here for colorspace 'gray' and 'rgb', but fails for 'cmyk'. The final graphic is empty (no shadow) in the later case.
If I use a different color than black (e.g. '+level-colors red') things work ok even with cmyk.
This (shortened and simplyfied) code is taken from an automatically generated test batch file ('blackening' an already black gfx still make no sense). :D

Am I missing something?

Code: Select all

convert ( -size 256x69 -density 96 xc:none -fill black -stroke none -strokewidth 0 -draw "roundrectangle 1,1 254,67 2,2" ) ^
  ( +clone -background black -shadow 50x2+0+0 +repage ) ^
  ( +clone +level-colors black ) ^
  -delete 0,1 -colorspace cmyk -units PixelsPerInch -set density 96 -quality 95 -background white -alpha remove "sh-2.jpg"
ImageMagick 6.7.8-2 2012-07-04 Q16 on Windows7-64bit
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: '+level-colors black' and cmyk result

Post by fmw42 »

+level-colors need two colors to be specified otherwise, it assumes some other color, but I am not sure what that is, perhaps black. So then you will translate all grayshades into black. Try black,white or white,black and see if that helps. Or put a comma before or after black. see http://www.imagemagick.org/Usage/color_ ... vel-colors
indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

Re: '+level-colors black' and cmyk result

Post by indiego »

Thanks for the quick reply. Tested with all combinations and the result is the same.
I have added a comma after the color to fit the requirements.

As I understand it, the same color is also used for the white point, if none is given.
The '-shadow' created graphic is unicolor (here always full black), only the opacity values vary. So one color should be enough here.
Also: this works in all other color spaces and with (as far as I have tested) all other colors. I'm puzzled.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: '+level-colors black' and cmyk result

Post by anthony »

Without a 'comma' in the arguemnt +level-color assumes the color is both the balck and white point, and thus replaces the whole image with that color.

You need two colors, OR at least a comma to indicate a unchanged color, for it to work.

See IM Examples,
http://www.imagemagick.org/Usage/color_ ... evel_color

Just remember +/-level-color is exactly as per +/-level but with the values specified using color names.

NOTE color names are not currently mapped to match the image colorspace. As such 'red' may not mean 'red' in a CMYK image.. (This may change in the near future)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

Re: '+level-colors black' and cmyk result

Post by indiego »

Without a 'comma' in the arguemnt +level-color assumes the color is both the balck and white point, and thus replaces the whole image with that color.
This is exactly what I want. I tried to 'replace' the color, but '+level-colors' was the only working method.
The idea behind it is to do the shadow calculation (umbra+preambra area and some modifications) in Gray colorspace and to colorize it in the final step.
NOTE color names are not currently mapped to match the image colorspace. As such 'red' may not mean 'red' in a CMYK image.. (This may change in the near future)
That sounded promising, but a test with color 'cmyk(0,0,0,255)' instead of 'black' also fails....
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: '+level-colors black' and cmyk result

Post by fmw42 »

why must you have the result in cmyk?
indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

Re: '+level-colors black' and cmyk result

Post by indiego »

Because CYMK is one of the supported color spaces. I write on a ConTeXt module, that uses IM to create drop shadows of squared areas (boxes). If someone needs to create CMYK only documents (no prepress step with proper color conversion before printing), this is the only way to go.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: '+level-colors black' and cmyk result

Post by fmw42 »

indiego wrote:Because CYMK is one of the supported color spaces. I write on a ConTeXt module, that uses IM to create drop shadows of squared areas (boxes). If someone needs to create CMYK only documents (no prepress step with proper color conversion before printing), this is the only way to go.
I doubt this will help, but try putting -colorspace CMYK at the very end before the output. Or save the rgb output and then convert to cmyk in another step. See if the rgb result is correct?
indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

Re: '+level-colors black' and cmyk result

Post by indiego »

I doubt this will help, but try putting -colorspace CMYK at the very end before the output.


...but it does. Works with 'black' now too!! :lol:

Many thanks!
Post Reply