A related question on this topic: viewtopic.php?f=1&t=26681. After conversion, I would like to adjust the CMYK levels. For offset printing images I want to make sure that each of C-M-Y is at least 5% everywhere, and K is maximum 85% everywhere, and the sum of C-M-Y-K is not more than 300%. C-M-Y should be adjusted equally, i.e. if my brightest point is 2-5-0-1 CMY should be increased across the board by 5 to 7-10-5-1 to avoid color casts.
I found the -modulate option, but that does not seems to work in CMYK. Plus, it seems to works in relative terms, increasing e.g. brightness by 20%: In my example, I don't want to multiply the Y component, which is zero, by a certain factor (which keeps it at zero), i want to add 5 points of Y, and 5 points of M, and 5 points of C.
The -channel option looks promising, it seems I can do something like "-channel CMY -evaluate Add 5" -- but how can I find the lowest value among CMY to see how much I have to add? And does convert use the 0-100% range for CMYK, as common in offset printing, or is it 0-255, or something else?
(It would be perfect if there were options to correct this automatically, something like "convert -cmy-min 5 -k-max 85 -cmyk-max 300". But I'm definitely happy if this works in any way...)
Adjust CMYK levels
Re: Convcert sRGB to CMYK
You might want to take a look at -fx 'http://www.imagemagick.org/script/fx.php'. You can manipulate the value of each pixel with that.
p.s. I have also moved your post to a new topic.
p.s. I have also moved your post to a new topic.
Re: Adjust CMYK levels
I guess my question was a bit misleading: In the end, I don't want to manipulate just single pixels. All changes need to be done globally, to avoid changing the look of the image (as far as possible) while making it printable. So it seems to me that I don't need something more complex than e.g. "-evaluate Add 5".
I guess I can use the "identify" channel statistics to know what is the lowest value among C, M, Y in the picture, but I am still unsure in which range this lowest value/my addition value is expressed.
Thanks for moving the topic!
I guess I can use the "identify" channel statistics to know what is the lowest value among C, M, Y in the picture, but I am still unsure in which range this lowest value/my addition value is expressed.
Thanks for moving the topic!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Adjust CMYK levels
I don't work in CMYK, but operations seem the same as when using RGB. See these example. Windows BAT syntax.Michael wrote:... but how can I find the lowest value among CMY to see how much I have to add?
Code: Select all
rem Create a sample CMYK file.
%IM%convert -colorspace CMYK xc:cmyk(2,5,0,1) xc:cmyk(45,56,67,80) +append -depth 8 c.tiff
%IM%convert c.tiff txt:
rem Find min and max values as percentages
%IM%convert c.tiff -format "%%[fx:100*minima] %%[fx:100*maxima]\n" info:
rem Find min and max values as absolute values (in Q16, as this convert is Q16)
%IM%convert c.tiff -format "%%[minima] %%[maxima]\n" info:
rem It seems that %%[maxima] respects -channel but %%[fx:100*maxima] doesn't.
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: Adjust CMYK levels
You can do [fx:100*maxima.r] to get the red channel. Similarly with .g and .b to get the green and blue channel data. You can combine them into one command to list all 3.snibgo wrote:It seems that %%[maxima] respects -channel but %%[fx:100*maxima] doesn't.
Re: Adjust CMYK levels
I successfully converted an example image from AdobeRGB to CMYK. "identify -verbose" says the lowest value of C is 8 (out of a range of 0-255) or 0.03 something in a range 0-1, so I want to add the missing bits to it to reach my 5% = 0.05.
I tried adding to it using -evaluate Add 5 or -evaluate Add 0.02, with or without specifying a channel, but nothing happened.
A command using -fx
The preview in scribus is good, but the "display" command seems to show inverse colors. is there a way around this?
I am using imagemagick ImageMagick 6.8.9-9 Q16 x86_64 2014-11-15 (Debian testing).
I tried adding to it using -evaluate Add 5 or -evaluate Add 0.02, with or without specifying a channel, but nothing happened.
A command using -fx
seems to work nicely. Thanks for your help!convert image.tiff -channel CMY -fx "u+0.02" -channel K -fx "u-0.09" output.tiff
The preview in scribus is good, but the "display" command seems to show inverse colors. is there a way around this?
I am using imagemagick ImageMagick 6.8.9-9 Q16 x86_64 2014-11-15 (Debian testing).
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Adjust CMYK levels
"-evaluate Add" units are either numbers within zero to Quantum, or percentages. To add 2%, use "-evaluate Add 2%". (If using Windows BAT syntax, double the % character.) " For Q16, Quantum is 65535. 2% of 65535 is 1310.7.Michael wrote:I tried adding to it using -evaluate Add 5 or -evaluate Add 0.02, with or without specifying a channel, but nothing
happened.
"-fx" is, as you have seen, in the range 0 to 1.
snibgo's IM pages: im.snibgo.com
Re: Adjust CMYK levels
Somehow it doesn't work as expected. I have uploaded a test image with a blown sky here. CMYK levels range from 0-100% for C and K and 0-97% for M and Y:
https://www.dropbox.com/s/0thn6x35znasp ... 5.jpg?dl=0
Now I would like to make sure that C,M,Y are at least 5% and K is maximum 85%.
convert imDSC3125.jpg -channel CMY -evaluate Add 5% -channel K -evaluate Subtract 15% im-corrected.jpg
or
convert imDSC3125.jpg -channel CMY -fx "u+0.05" -channel K -fx "u-0.15" im-corrected-fx.jpg
should do it, as far as I understand.
With both command lines, minimum levels for C,M,Y are 1,2%, 2,4%, 2,7% respectively. K is maximum 86,7%. So where's the error?
EDIT: Maybe it's a JPEG compression issue? I just tried the same thing with tiff files: The ranges in the source file are already different, and the math works as expected.
https://www.dropbox.com/s/0thn6x35znasp ... 5.jpg?dl=0
Now I would like to make sure that C,M,Y are at least 5% and K is maximum 85%.
convert imDSC3125.jpg -channel CMY -evaluate Add 5% -channel K -evaluate Subtract 15% im-corrected.jpg
or
convert imDSC3125.jpg -channel CMY -fx "u+0.05" -channel K -fx "u-0.15" im-corrected-fx.jpg
should do it, as far as I understand.
With both command lines, minimum levels for C,M,Y are 1,2%, 2,4%, 2,7% respectively. K is maximum 86,7%. So where's the error?
EDIT: Maybe it's a JPEG compression issue? I just tried the same thing with tiff files: The ranges in the source file are already different, and the math works as expected.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Adjust CMYK levels
JPEG uses lossy compression, which means it changes colours. "-quality 100" will reduce but not eliminate this effect.
snibgo's IM pages: im.snibgo.com