Color Space information from image files (PSD, PSB, AI)

Started by joseph, May 07, 2016, 07:52:57 PM

Previous topic - Next topic

joseph

I'm running exiftool on several PSD, PSB, and AI files to extract color space information.  For many of these files, I'm not receiving any kind of color space value.  When I examine the files, I'm not seeing a Color Space value to use.  I do some times see other values such as Swatch Groups Colorant Mode, Color Space Data, etc.  Are these accurate? Am I missing something when extracting the metadata from these files?  I'm currently running the tool without any flags set.

Phil Harvey

There is much image information in these file types that is not currently extracted.  Without checking the photoshop specification I couldn't say whether or not color space information is extracted, but it sounds like it isn't.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

joseph

Thanks Phil.  I'm getting different results, but these files should all be prepped with the same version of Photoshop CC 2015 (15.1.2).  Is there anything I can send you that would help you determine whether the Color Space can be extracted?

joseph

This is the tag in the illustrator file that I'm looking for: %AI9_ColorModel: 2

I grabbed that from examining the illustrator file in a text editor.  Is there a way to extract this using exiftool?

Phil Harvey

Quote from: joseph on May 20, 2016, 06:07:05 PM
Is there a way to extract this using exiftool?

It depends on where the tag is located.  ExifTool will extract it with the name AI9_ColorModel if it is in the document header.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

joseph

I took a look at it closer and it doesn't appear to be in the document header.  It's embedded somewhere in the middle of the AI file between %!PS-Adobe-3.0 and %%EndComments.

Phil Harvey

I would think it should be extracted if it is in the comments section.  Can you send me a sample?  (philharvey66 at gmail.com)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

joseph

I just sent you an email.  Also wondering about colorspace in jpeg files.  I've attached the jpeg example file.

In ImageMagick, it will show up as sRGB, but does not display any color profile with exiftool.

Phil Harvey

I got the AI sample.  Looking at the exiftool -v4 output, I can see the AI9_ColorModel tag inside the AIMetaData stream that ExifTool currently isn't decoding.  I will look into decoding this metadata, but I don't know if this will help you much (AI9_ColorModel has a value of "2" -- is this meaningful to you?)

The JPEG you posted has no color space information, so I presume that ImageMagick is defaulting to sRGB.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

joseph

Thanks again for taking a look.  The value for AI9_ColorModel is very helpful to me.  If it has a value of 1, then the Color Model is RGB.  If it has a value of 2, then the Color Model is CMYK.

Thanks for also looking at the JPEG.  The exiftool helps a lot with this since we're just looking at the number of color components to determine 3 (RGB) vs 4 (CMYK).

Stephen Marsh

Quote from: Phil Harvey on May 27, 2016, 04:07:43 PM
I got the AI sample.  Looking at the exiftool -v4 output, I can see the AI9_ColorModel tag inside the AIMetaData stream that ExifTool currently isn't decoding.  I will look into decoding this metadata
- Phil

There is no exiftool -AI9_ColorModel FILE command, so did this hit a brick wall?

I can see the text buried deep in the -v4 dump, but how to make use of it?

Phil Harvey

Sorry Stephen, I dropped the ball on this one.

I can add the ability to extract any of this from the file you sent:

%AI5_FileFormat 13.0
%AI12_BuildNumber: 147
%AI3_ColorUsage: Color
%AI7_ImageSettings: 0
%%CMYKProcessColor: 1 1 1 1 ([Registration])
%AI3_Cropmarks: -24.3396107530862 -27.5621559669089 875.660389246914 572.437844033093
%AI3_TemplateBox: 425 130 425 130
%AI3_TileBox: -208.979855995178 -123.562155966909 1015.02014400482 668.437844033091
%AI3_DocumentPreview: None
%AI5_ArtSize: 14400 14400
%AI5_RulerUnits: 6
%AI9_ColorModel: 2
%AI5_ArtFlags: 0 0 0 1 0 0 1 0 0
%AI5_TargetResolution: 800
%AI5_NumLayers: 2
%AI17_Begin_Content_if_version_gt:17 1
%AI9_OpenToView: -323.5 581.5 1 1495 600 18 1 0 70 154 0 0 0 1 1 0 1 1 0 0
%AI17_Alternate_Content
%AI9_OpenToView: -323.5 581.5 1 1495 600 18 1 0 70 154 0 0 0 1 1 0 1 1 0 0
%AI17_End_Versioned_Content
%AI5_OpenViewLayers: 73
%%PageOrigin:0 0
%AI7_GridSettings: 72 8 72 8 1 0 0.800000011920929 0.800000011920929 0.800000011920929 0.899999976158142 0.899999976158142 0.899999976158142
%AI9_Flatten: 1
%AI12_CMSettings: 00.MO


Is there anything else useful to you besides the ColorModel?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Stephen Marsh

Hi Phil, sorry for dredging up an old topic, however I was looking to identify whether native Adobe Illustrator files were RGB or CMYK mode and found this topic.

I am not sure what else will be useful from that chunk of data, you know how it goes – it is only useful when one has a need for it! :]

I was thinking of something similar to:

exiftool -if '$AI9_ColorModel eq "1"' -label='Review' -execute -if '$AI9_ColorModel eq "2"' -label='Select' -execute -common_args -r 'DIR'

Or perhaps:

exiftool -if '$AI9_ColorModel eq "1"' -directory=%d'RGB AI File' -execute -if '$AI9_ColorModel eq "2"' -directory=%d'CMYK AI File' -common_args -r 'DIR'


Phil Harvey

OK Stephen,

ExifTool 10.93 (just released) extracts this as "AIColorModel", and the values are converted as 1=sRGB and 2=CMYK, so your first command should look like this:

exiftool -if '$AIColorModel eq "sRGB"' -label='Review' -execute -if '$AIColorModel eq "CMYK"' -label='Select' -execute -common_args -r 'DIR'

I've also extracted these tags for the fun of it:

AIColorUsage     
AIRulerUnits     
AITargetResolution
AINumLayers       
AIFileFormat     
AICreatorVersion 
AIBuildNumber   

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

Ooops.  I just realized this should probably be "RGB", not "sRGB" :(

Maybe use -if '$AIColorModel =~ /RGB/' to be compatible with 10.94 if I change this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Stephen Marsh

Agreed Phil, I was just typing out my justification for disagreement! :]

Thank you Phil! This is sweet, Adobe don't even offer an out of the box solution for this in Adobe Bridge.

A small point of disagreement, I personally believe that the result of AI9_ColorMode: 1 should be indicated as:

AI Color Model : RGB

Rather than:

AI Color Model : sRGB

As the colour mode/model (RGB) is independent of the specific colour space (sRGB, Adobe RGB 1988, ProPhoto RGB etc). My test file had no ICC profile, so it should not be automatically assumed to be sRGB, it is just "mystery meat" RGB.

Just as AI9_ColorMode: 2 is simply shown as a simple colour mode/model of "CMYK" rather than as a specific colour space name.

Phil Harvey

Yes.  See my previous post.  I'll fix this for 10.94
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Stephen Marsh

Haha:

-if '$AIColorModel eq "RGB"'
-if '$AIColorModel =~ /RGB/'


The great thing about ExifTool (Perl) is it's ability to confound uninitiated users with the flexibility of it's command line syntax!

Phil Harvey

Quote from: Stephen Marsh on April 13, 2018, 11:39:27 AM
The great thing about ExifTool (Perl) is it's ability to confound uninitiated users with the flexibility of it's command line syntax!

We aim to please. ;)
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Hayo Baan

Quote from: Stephen Marsh on April 13, 2018, 11:39:27 AM
Haha:

-if '$AIColorModel eq "RGB"'
-if '$AIColorModel =~ /RGB/'


The great thing about ExifTool (Perl) is it's ability to confound uninitiated users with the flexibility of it's command line syntax!
The two are different though; the first will only match the exact string RGB, the latter any string with RGB in it. So the latter will (also) match sRGB while the first won't :)
Hayo Baan – Photography
Web: www.hayobaan.nl

StarGeek

Quote from: Stephen Marsh on April 13, 2018, 11:39:27 AMThe great thing about ExifTool (Perl) is it's ability to confound uninitiated users with the flexibility of it's command line syntax!

Must... confuse... moar!

-if "index($AIColorModel,'RGB)==0"

It will only match if the tag starts with "RGB", so it won't match "sRGB", but it would match if something followed "RGB".
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Stephen Marsh

Quote from: Hayo Baan on April 17, 2018, 08:54:48 AM

The two are different though; the first will only match the exact string RGB, the latter any string with RGB in it. So the latter will (also) match sRGB while the first won't :)

Thanks Hayo, just when I thought that I knew what was going on! :]

This is really useful stuff!

Stephen Marsh

Quote from: StarGeek on April 17, 2018, 07:52:20 PM

Must... confuse... moar!

-if "index($AIColorModel,'RGB)==0"

It will only match if the tag starts with "RGB", so it won't match "sRGB", but it would match if something followed "RGB".

So it is the equivalent of a regex of:

^RGB

or do you mean:

\b^RGB\b

StarGeek

More like ^RGB but only because I checked to see if it was equal to 0.  From the Perl docs:

"The index function searches for one string within another, but without the wildcard-like behavior of a full regular-expression pattern match. It returns the position of the first occurrence of SUBSTR in STR..."

By changing it to >=0 it would become the equivalent of /RGB/.  Adding the word boundries \b would be more complicated than it's worth for index.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).