Quark Users - Check for RGB Images !!!

Hello Quark Scripters,

I know there are plenty or preflight programs and xtensions that can check to see if a Quark document contains placed RGB images.

I am wondering if any of you have been able to do this using applescript.

I tried the following script to get image properties. It appears that these properties don’t contain color space data (RGB). Maybe there is another way.

Code:

tell application “QuarkXPress”
tell document 1
set IMAGE_PROPERTIES to properties of every image
end tell
end tell

Any information would be greatly appreciated,
CarbonQuark

Hi Carbon

Don’t think this is do-able in quark!! (could be wrong)
You will have to probably point the file towards image events to retrieve the color space.
the problem there is image events dosen’t like eps files, so you would have to direct any eps’s to some other
app, maybe photoshop or graphic convertor or maybe some other! not sure if there is any background apps like image events
that like eps files…(photoshop would have to open open up before it would release a files color space info etc…)
starts to get messy when you need loads of apps…

Hey pidge1,

Thanks for the reply.

I am not familiar with image events. I will look into it… maybe it will work. Someone on another forum suggested that I have the script do a collect for output (report only). The collect report contains the color space data for every image.

I could parse this information from the report. However, this seems like a clunky way of going about this.

I will continue to research.

Thanks!
CarbonQuark

Carbon, I would agree with pidge’s comments Image events and SIPS won’t deal with .eps and as a Quark user this is a much used file format. The only way that I know would be to open images in Photoshop and illustrator and this is not a very practical solution. Other routes would most likely require additional apps and if that were the case then you may as well invest in the XT’s. Personally I just PDF everything and preflight in acrobat to check colour space. BTW I don’t think the collect for output function is in the dictionary.

Hi Mark67,

Thanks for the information!

I started experimenting with the following code and I have had success even with .eps files. It’s not entirely fool proof but should work most of the time (good enough for what I need). As you probably know an image file can be read as text. This script does a simple search in this text for the text “RGB”. A CMYK file typically doesn’t contain the text “RGB”. The only problem is it is slow on large files.


set IMAGE_FILE to choose file 
set FILE_DATA to read IMAGE_FILE 
set COLOR_SPACE to "CMYK" 
if FILE_DATA contains "RGB" then set COLOR_SPACE to "RGB" 
return COLOR_SPACE 

Still working on the best solution… I will post once I figure it out. Any more suggestions would be greatly appreciated.

CarbonQuark

Hi Carbon,

two ideas for your speed problem - you could …

  • use the file parsing method only as second solution when other methods fail
  • use cat & grep in a shell script for file parsing instead of applescript’s ‘read’ and ‘contains’ (might be faster - I am not sure)

Here an example (using the shell command ‘mdls’ to search the image file’s meta data for color space information as first method):

set img to choose file
if (my checkRGB(img)) then
	display dialog "An RGB image"
else
	display dialog "Other color space"
end if

on checkRGB(theImg)
	set imgPath to quoted form of (POSIX path of theImg)
	set mdlsResult to ""
	try
		set mdlsResult to (do shell script "mdls " & imgPath & " | grep kMDItemColorSpace")
	end try
	if mdlsResult ≠ "" then
		if mdlsResult contains "RGB" then
			return true
		else
			return false
		end if
	else
		try
			do shell script "cat " & imgPath & " | grep -e'.*[Rr][Gg][Bb].*'"
			return true
		on error
			return false
		end try
	end if
	
end checkRGB

Note: the file parsing method fails when the image data accidentally contains the bytes of ‘RGB’. For example I found the String ‘RGB’ in CMYK-Freehand-eps files

Dominik

Carbon, to start with I would try separating the files IE can deal with and work around the ones it can’t. Here is some basic bones you may want to work up. I’ve only knocked this together quickly. If I get the time I will try to work out some ideas for the problematic eps & pdf handling if you can get the creator types this should not be too difficult. Im not sure if you can get Photoshop and illustrator (or what apps you have) to open files invisibly or may be the parsing file but Im unfamiliar with this. As a rule I never put pdf in quark so I could rule that out for a start. This should get you off the ground anyhow.

property CreatorType : {missing value, "8BIM"}
property OtherTypes : {"ART5", "CARO", "XPR3"} -- To be used in handling EPS & PDF
property IETypeList : {"8BIM", "BMP ", "GIFf", "JPEG", "PICT", "PDF ", "8BPS", "TIFF"}
property IEExtList : {"bmp", "gif", "jpg", "pct", "pdf", "psd", "tif"}
--
tell application "QuarkXPress"
	activate
	set DocName to name of document 1
	tell document DocName
		set ImageList to {}
		repeat with ImageNum from 1 to count of image
			tell image ImageNum
				set PictureName to (file path as text)
				if ImageList does not contain PictureName then
					set end of ImageList to PictureName
				end if
			end tell
		end repeat
	end tell
end tell
--
set IEformats to {}
tell application "Finder"
	repeat with this_item in ImageList
		set this_item to this_item as alias
		set X to properties of this_item
		if (name extension of this_item is in IEExtList) or (file type of this_item is in IETypeList) then ¬
			copy (this_item as string) to end of IEformats
	end repeat
end tell
--
set RGBList to {}
--
tell application "Image Events"
	repeat with ThisImage in IEformats
		set theFile to open ThisImage as alias
		if (color space of theFile is RGB) then copy (name of theFile as string) to end of RGBList
		close theFile saving no
	end repeat
end tell
--
if (count of (items of RGBList)) < 1 then
	set theDialog to "No RGB Images."
	display dialog theDialog default button 1 giving up after 3
else
	set ASTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to return
	set ImageNames to items of RGBList as string
	set AppleScript's text item delimiters to ASTID
	set theDialog to "The following images are RGB." & return & return & ImageNames
	display dialog theDialog default button 1
end if

Mark67 and Dominik,

Thanks for the information!

I will go thru the scripts you presented and do further testing.

CarbonQuark

Carbon, in the finder tell block you should be able to sort the other file formats and may be pass each off to handlers depending on what you wish to do with each. IE is very fast so that’s why I’d let it do what it can first.

Mark67,

Good Idea! Thanks.

CarbonQuark