Quite basic question:
Is -colorspace an option I can use to the identify command?
I want to identify quite simply the colorspace from a JPG image (grayscale, RGB, CMYK) without the overloaded details from the -verbose option.
Following command line: identify -colorspace input.jpg
gives me 'identify: option requires an argument '-colorspace'?
Thanks for your input.
using colorspace as an option to identify
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: using colorspace as an option to identify
It would not be -colorspace but a -format option if it exsists.
Unfortunately it doesn't. Many verbose "identify" output information lines do not have -format code entries, you can request one, but then that will only be available in the very latest IM.
You have two soultions. use a programing language API like PerlMagick, or MagickWand etc.. that MAY allow you access to that info (I have NOT checked though I have used that info in the lowest level MagickCore library functions). Using an language API also means you only read the image once only, rather than multiple times as you get with the command line API.
The other option is to parse the verbose identify output. For example...
NOTE: the colorspace is the internal representation of the image in-memory. For its File Format representation you would look at "Type" not "ColorSpace". Type is output as part of the standard non-verbose single-line-per-image output of "identify", that may do want you want, but it may be harder to parse that a verbose report.
Unfortunately it doesn't. Many verbose "identify" output information lines do not have -format code entries, you can request one, but then that will only be available in the very latest IM.
You have two soultions. use a programing language API like PerlMagick, or MagickWand etc.. that MAY allow you access to that info (I have NOT checked though I have used that info in the lowest level MagickCore library functions). Using an language API also means you only read the image once only, rather than multiple times as you get with the command line API.
The other option is to parse the verbose identify output. For example...
Code: Select all
identify -verbose image.jpg | grep Colorspace:
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: using colorspace as an option to identify
Anthony,
Thanks for putting me on the right track. Sorry, I should have read your pages about basic options first.
I need to read the colorspace (grayscale, RGB, CMYK) from a jpg file so the actual file format 'Type' is the one I'm looking for. Though, if I want to use:
identify -verbose image.jpg | grep "Type:"
identify -verbose image.jpg | grep Type:
identify -verbose image.jpg | grep Colorspace:
...
'grep' is not recognized as an internal or external command, operable program or batch file?
jsa
Thanks for putting me on the right track. Sorry, I should have read your pages about basic options first.
I need to read the colorspace (grayscale, RGB, CMYK) from a jpg file so the actual file format 'Type' is the one I'm looking for. Though, if I want to use:
identify -verbose image.jpg | grep "Type:"
identify -verbose image.jpg | grep Type:
identify -verbose image.jpg | grep Colorspace:
...
'grep' is not recognized as an internal or external command, operable program or batch file?
jsa
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: using colorspace as an option to identify
grep is a standard 'search for lines containing string' program under UNIX and UNIX-like systems. There are DOS versions available.
Its functionality is also available in higher level scripting languages such as "perl" too
For exampleis the perl equivalent to
Its functionality is also available in higher level scripting languages such as "perl" too
For example
Code: Select all
perl -n "print if /^Type:/"
Code: Select all
grep '^Type:'
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/