• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Making Photoshop Swatches With Script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making Photoshop Swatches With Script


  • Subject: Re: Making Photoshop Swatches With Script
  • From: Stan Cleveland <email@hidden>
  • Date: Thu, 13 Dec 2012 15:36:09 -0800

On Dec 13, 2012, at 2:24 PM, Simon, Garry wrote:

Hey, do any of you guys know how to create new swatches in Photoshop’s “Swatches” palette, either with a script or script/action combination? The idea is to feed in parameters (swatch name, color space, values) and have swatches made. I don’t even see “swatch” in Photoshop’s scripting dictionary…

Hi Garry,

Here's what I put together years ago. It still works in Photoshop CS5. Be forewarned that the code contains no error trapping or data validation, such as whether the provided color name already exists.

AFAIK, there's no way to make a swatch without _javascript_. I took advantage of Adobe's ScriptingListener plug-in to capture the raw code, which I cleaned up and made more human-readable.

HTH,
Stan C.

set colorName to "Some Green"
set cPercent to 50.0
set mPercent to 5.0
set yPercent to 100.0
set kPercent to 25.0
makeNewSwatch(colorName, cPercent, mPercent, yPercent, kPercent)

on makeNewSwatch(colorName, cPercent, mPercent, yPercent, kPercent)
tell application "Adobe Photoshop CS5"
activate
do _javascript_ ("function makeNewSwatch(colorName, cPercent, mPercent, yPercent, kPercent)
{
var emptyColor = new ActionReference();
emptyColor.putClass( charIDToTypeID( \"Clrs\" ) );
var colorParameters = new ActionDescriptor();
colorParameters.putDouble( charIDToTypeID( \"Cyn \" ), cPercent );
colorParameters.putDouble( charIDToTypeID( \"Mgnt\" ), mPercent );
colorParameters.putDouble( charIDToTypeID( \"Ylw \" ), yPercent );
colorParameters.putDouble( charIDToTypeID( \"Blck\" ), kPercent );
var colorDefinition = new ActionDescriptor();
colorDefinition.putString( charIDToTypeID( \"Nm  \" ), colorName );
colorDefinition.putObject( charIDToTypeID( \"Clr \" ), charIDToTypeID( \"CMYC\" ), colorParameters );
var newSwatch = new ActionDescriptor();
newSwatch.putReference( charIDToTypeID( \"null\" ), emptyColor );
newSwatch.putObject( charIDToTypeID( \"Usng\" ), charIDToTypeID( \"Clrs\" ), colorDefinition );
executeAction( charIDToTypeID( \"Mk  \" ), newSwatch, DialogModes.NO );
}
makeNewSwatch(  arguments[0] , arguments[1] , arguments[2] , arguments[3] , arguments[4]  );") ¬
with arguments {colorName, cPercent, mPercent, yPercent, kPercent}
end tell
end makeNewSwatch

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Making Photoshop Swatches With Script (From: "Simon, Garry" <email@hidden>)

  • Prev by Date: Making Photoshop Swatches With Script
  • Next by Date: Acrobat Sort By Size
  • Previous by thread: Making Photoshop Swatches With Script
  • Next by thread: Acrobat Sort By Size
  • Index(es):
    • Date
    • Thread