Selecting items that make the script fail. (Illus. Embedded Images)

One can get the color space of an embedded image in Illustrator CS. But it will only throw back values of CMYK, Gray, or RGB. This is fine, but if the file has an embedded transparent CMYK, RGB, or Grayscale image, the following script will fail?

I am only concerned with those transparent files that make the script fail. Can anyone help me figure out a way to have the script tell Illustrator to make those transparent embedded images the only selected items within the document?

Many thanks in advance, if someone is willing to look into this.
-Jeff

tell application "Illustrator CS"
	set refDoc to current document
	set x to every raster item of refDoc
	repeat with y in x
		set colorSpace to color space of y
	end repeat
end tell

Hi Jeffkr

Had a little play around with this one with some success (i think!!)
i found that if my image is a linked eps for example it doesn’t give you a color space whereas an embedded one will give you a color space, when you rasterize
the image then you get missing value for the color space which i believe is what is throwing up you error.
also if you notice with the properties once an image is embedded the file path changes to "library:application support:adobe:fonts:cmaps"or something like that, so you need to use the 2 properties together to get your selection, you need the file path to find the embedded image and missing value in the color space to narrow it down to the rasterized (transparent) image. phew!!

property s : missing value

tell application "Illustrator CS"
	tell document 1
		repeat with i from 1 to count of every raster item
			set p to properties of raster item i
			set f to get file path of p
			set c to color space of p
			if the file path of raster item i is equal to f and the color space of p is equal to s then
				set name of raster item i to "jeffkr"
			end if
		end repeat
		delete (every raster item whose name is "jeffkr")
	end tell
end tell

This seemed to be working for me but you’ll just have to give it a go cause we may have a different setup across machines…

pidge1,
You really outdid yourself this time. If you only knew how useful this will be! I modified it ever so slightly to select those items, rather than delete. Btw, the reason I asked for such a thing is because Illustrator appears to invert embedded grayscale images that contain transparent backgrounds when placed into InDesign. Therefore, I want to have those objects selected (in Illustrator) and the run the filter Color>Convert to CMYK, prior to saving. My entire save script does a lot more. But this was the one missing link.

The concepts of tracing the file path within the script is a fundamental aspect that I am very oblivious to, similar to most of this stuff :slight_smile:

But over time, a few things are seeming to connect.

Thanks again,
Jeff