How to convert image profiles with ColorSyncScripting?

I want to convert an RGB image to CMYK using specific profiles. Just like in Photoshop where we use “Assign Profile …” with source profile then “Convert to Profile …” with destination profile.

I prefer using ColorSyncScripting because it performs the tasks quietly, unlike in Photoshop it need to open up the images to do the conversion.

My attempt is as follows but nothing happen. I could not figure out where the error come from, please advise. Thanks!

set theImage to choose file with prompt "choose a RGB image..." without invisibles
tell application "ColorSyncScripting"
	launch
	open theImage
	set inProfile to "AppleRGB"
	set outProfile to "CoatedFOGRA27"
	match theImage from source inProfile to destination outProfile matching with absolute colorimetric intent using quality best saving into theImage with replacing
	close theImage
end tell

Hi,

you try to assign literal strings, not profiles


set theImage to choose file with prompt "choose a RGB image..." without invisibles
tell application "ColorSyncScripting"
	launch
	open theImage
	set inProfile to "AppleRGB"
	set outProfile to "CoatedFOGRA27"
	match theImage from source profile inProfile to destination profile outProfile matching with absolute colorimetric intent using quality best saving into theImage with replacing
	close theImage
end tell

Thank you StefanK for your prompt reply.
But I have no luck, nothing has been done to the image file.

Are the profiles named correctly?
With this snippet you get a list of all profiles


tell application "ColorSyncScripting"
	launch
	set allProfiles to name of profiles
end tell
set newProfile to choose from list allProfiles

Thanks again. StefanK!

I tried replacing the profile names which I obtain from your script, still not successful.

set theImage to choose file with prompt "choose a RGB image..." without invisibles
tell application "ColorSyncScripting"
	launch
	open theImage
	set inProfile to "Apple RGB (1998)"
	set outProfile to "Coated FOGRA27 (ISO 12647-2:2004)"
	match theImage from source profile inProfile to destination profile outProfile matching with absolute colorimetric intent using quality best saving into theImage with replacing
	close theImage
end tell

Btw, I check the dictionary on the “match” command, it stated:

match list of image : an image file alias

I don’t understand this definition, is my mistake somehow related to the image file name?

Thanks!

Found something!

I simplify the script to figure out where is giving problem:

set theImage to choose file with prompt "choose a RGB image..." without invisibles
set inProfile to "Adobe RGB (1998)"
set outProfile to "Coated FOGRA27 (ISO 12647-2:2004)"
tell application "ColorSyncScripting"
	embed theImage with source profile inProfile
	--match theImage to destination profile outProfile
end tell

The above script works fine! But when we add in the match command, it will prompt an error of:

ColorSyncScripting got an error: An error of type -176 has occurred.

Is “match” command the culprit?

If it is so, then any work-around? If not, then where is the problem?

I realize this reply is just over a year too late … but I’m posting in case it helps someone on the “intertubes”.

It took me a while to figure this out, and an awful lot of banging my head into the wall … You’re close, and you’re doing what you would expect to be “the right thing”.

You’re using the profile -name-, not the profile object as the source.

But wait! Even that won’t work. ColorSyncScripting expects the profile -file-, not the profile.

I know, this is strange. But check out the script inside “Embed display profile.app” in /Library/Scripts/ColorSync/ and you’ll see the creator of the sample sources an alias to the profile file, not the profile.

And, no, there seems to be no easy way to take a profile name (which works in a prompt list) and back into a profile file. (I’ve tried several different approaches. )

If anyone has ideas and suggestions, please post away.