Posted: Tue Nov 02, 2010 10:16 pm Post subject: applescript RGB to CMYK
I've written a script which does among other things converts RGB images to CMYK. When this conversion is done photoshop uses the current settings loaded in Color Settings to set GCR, dot gain, and other settings. So the script checks to make sure that a properly named settings exist. This works, but I would far prefer to applescript the Color Settings and set them directly when doing the Change Mode, or to be able to directly set them without relying on a specific Color Setup existing. This script will be used in a number of locations and I can't rely on the proper Color Setup existing or being properly configured, either option either stopping the script or resulting in an improper conversion.
I've seen references to Change Mode Options, but haven't been able to find anything specific as to what options I can set or what the syntax is. I've found no information as to how to directly set the values for Color Settings Preferences.
Not everything is doable via the DOM. A lot of the time you need to install the ScriptListener plugin and use the Action Manager code that it produces. As this will be javaScript you would have to use doJavascript in your appleScript.
Here is an example of checking the document mode and setting the color working space.
Code:
setColorSetting();
function setColorSetting() {
if(!documents.length) return;
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putProperty( charIDToTypeID('Prpr'), stringIDToTypeID('colorSettings') );
ref.putEnumerated( charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
var desc2 = new ActionDescriptor();
switch(activeDocument.mode){
case DocumentMode.CMYK : desc2.putString( stringIDToTypeID('workingCMYK'), "U.S. Web Coated (SWOP) v2" );break;
case DocumentMode.RGB : desc2.putString( stringIDToTypeID('workingRGB'), "sRGB IEC61966-2.1" ); break;
case DocumentMode.GRAYSCALE : desc2.putString( stringIDToTypeID('workingGray'), "Dot Gain 20%" ); break;
default : return;
}
desc.putObject( charIDToTypeID('T '), stringIDToTypeID('colorSettings'), desc2 );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum