Getting colorspace using identify

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
martinw17
Posts: 39
Joined: 2006-09-07T02:10:27-07:00
Location: Brighton, UK

Getting colorspace using identify

Post by martinw17 »

I am trying to find out the colorspace of an image using a command-line call.
identify -format %r myimage.jpg
gives me the colorspace, but this is concatenated onto the end of the image class (with no space).

Is it possible to get the colorspace without the image class?

If not, what are the possible values for image class? Is this the complete set:
DirectClass
PseudoClass?

(Knowing that enables me to parse the output to obtain the colorspace).

Thanks,
Martin
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The image class is one of DirectClass or PseudoClass. To get just the colorspace you need the -verbose option of the identify command:
  • idenitfy -verbose myimage.jpg
martinw17
Posts: 39
Joined: 2006-09-07T02:10:27-07:00
Location: Brighton, UK

Post by martinw17 »

I am trying to get the colorspace without having to parse the results of identify -verbose.
If the image class will only ever be one of DirectClass or PseudoClass then that helps, as I can use -format %r.

Thanks for your help.

Regards,
Martin
uprocka

why ?

Post by uprocka »

I have the same problem:

identify -format %r produces the following output:

DirectClassCMYK

That makes no sense if I just want to know the Colorspace...

Why is there no % command to get the return value: e.g. CMYK


no I have to parse the returnvalue... :(
DemonDVA
Posts: 1
Joined: 2012-04-12T22:53:32-07:00
Authentication code: 8675308

Re: Getting colorspace using identify

Post by DemonDVA »

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Getting colorspace using identify

Post by anthony »

Actually I'd look at %[channels] too these are a little mixed up in IMv6.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
qubodup
Posts: 31
Joined: 2009-10-07T13:11:41-07:00
Authentication code: 8675309

Re: Getting colorspace using identify

Post by qubodup »

DemonDVA wrote:just use %[colorspace] (http://www.imagemagick.org/script/escape.php)
To clarify, the command

Code: Select all

identify -format %[colorspace] test.jpg
can be used to get a string like for example 'sRGB' or 'Gray' with no newline ending.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Getting colorspace using identify

Post by fmw42 »

you can introduce a new line ending by

Code: Select all

identify -format "%[colorspace]\n" test.jpg
Post Reply