Reporting CMYK values

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
robert81
Posts: 7
Joined: 2018-08-17T05:03:19-07:00
Authentication code: 1152

Reporting CMYK values

Post by robert81 » 2018-08-20T08:51:44-07:00

Hi !

Is there any source code or command line for reporting CMYK values automatically in a text file?
Suppose a 10*10 pixel image...is there any code to read the image and report each pixel CMYK value (values between 0-100) and export to a text file?

I have installed ImageMagick-7.0.8-10-Q16-x64-dll.exe on my 64-bit Windows. I open the image but there is no field in the software to enter any command line.

I am a little confused to start from which point? I do not know where I should open the image and run the command line.

Many thanks

User avatar
fmw42
Posts: 25384
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Reporting CMYK values

Post by fmw42 » 2018-08-20T09:40:36-07:00

Imagemagick is a command line tool and does not generally have a GUI. So you open a terminal window and type commands.


For the upper left 10x10 region, try

Code: Select all

magick image[10x10+0+0] -colorspace CMYK txt:- > file.txt
This will give more information, but the last column will be CMYK in the range 0-255. The numbers in parenthesis are CMYK in the range 0 to quantumrange. For Q16 Imagmagick, that would be 0-65535. So you can convert to range 0 to 100 by multiplying by 100/655535.

see https://www.imagemagick.org/Usage/files/#txt

Also you can get any one pixel value in your range 0 to 100 by (for the top left corner pixel)

Code: Select all

magick image[1x1+0+0] -colorspace CMYK -format "%[fx:u.c*100],%[fx:u.m*100],%[fx:u.y*100],%[fx:u.k*100]" info:- > file.txt
So you could write some looping code over each pixel that you desire and issue this command


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown

robert81
Posts: 7
Joined: 2018-08-17T05:03:19-07:00
Authentication code: 1152

Re: Reporting CMYK values

Post by robert81 » 2018-08-20T10:32:40-07:00

Dear fmw42,

Thank you for your advice.
I place the image file in a folder and run the command but it sent back an error...
magick: no decode delegate for this image format @error/constitute.c/readimage/554

I tried both image and image.jpg but there is the same error.

User avatar
fmw42
Posts: 25384
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Reporting CMYK values

Post by fmw42 » 2018-08-20T10:36:07-07:00

You have to use the actual name of your image file. I just put "image" for a generic image. What is the name of your image file?

You also need to either change directories to the directory holding your image file or add the path to image file from where you are running the command. So into what directory did you put your image? What is your home/working directory that shows when you open your terminal window?


What was your exact command that you used?


What do you get from

Code: Select all

magick -version

robert81
Posts: 7
Joined: 2018-08-17T05:03:19-07:00
Authentication code: 1152

Re: Reporting CMYK values

Post by robert81 » 2018-08-20T11:36:28-07:00

I think i did not enter correct command at first.
now it reports the results in the text file.
Thank you for your help! : - )

my image pixels is 594*584. this is the first lines of the result text:

# ImageMagick pixel enumeration: 594,584,65535,cmyk
0,0: (0,33257,42060,48316) #0081A4BC cmyk(0,129,164,188)
1,0: (0,34280,43354,48830) #0085A9BE cmyk(0,133,169,190)
2,0: (0,33272,42346,48830) #0081A5BE cmyk(0,129,165,190)
3,0: (0,32278,41082,48316) #007EA0BC cmyk(0,126,160,188)
4,0: (0,30840,41441,48059) #0078A1BB cmyk(0,120,161,187)
5,0: (0,29344,40104,48316) #00729CBC cmyk(0,114,156,188)
6,0: (0,28493,38941,47802) #006F98BA cmyk(0,111,152,186)
7,0: (0,28086,38385,47545) #006D95B9 cmyk(0,109,149,185)
8,0: (0,28339,38081,46517) #006E94B5 cmyk(0,110,148,181)

User avatar
fmw42
Posts: 25384
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Reporting CMYK values

Post by fmw42 » 2018-08-20T12:31:50-07:00

That is the proper expected results. So you have done that successfully.

robert81
Posts: 7
Joined: 2018-08-17T05:03:19-07:00
Authentication code: 1152

Re: Reporting CMYK values

Post by robert81 » 2018-08-23T08:28:12-07:00

Yes ...Thanks

I am just curious that if commercial printers use similar codes in their drivers to print a color image on paper?

Post Reply