Page 1 of 1

'+level-colors black' and cmyk result

Posted: 2012-07-15T13:46:42-07:00
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

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

Posted: 2012-07-15T13:57:54-07:00
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

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

Posted: 2012-07-15T14:23:42-07:00
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.

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

Posted: 2012-07-15T16:58:49-07:00
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)

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

Posted: 2012-07-16T03:03:04-07:00
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....

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

Posted: 2012-07-16T10:15:09-07:00
by fmw42
why must you have the result in cmyk?

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

Posted: 2012-07-16T11:08:05-07:00
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.

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

Posted: 2012-07-16T11:33:51-07:00
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?

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

Posted: 2012-07-17T05:38:41-07:00
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!