Copy link to clipboard
Copied
The "resize image" command in AppleScript performs the Image Size command in Photoshop.
However, with the AppleScript's command, the Scale Styles option is not enabled. Which, obviously, leads to undesired results in many cases.
Unless I'm missing something, there's no way to enable the Scale Styles option in AppleScript.
So I hope Adobe can add this parameter to the "resize image" command in AppleScript.
Thanks,
Leo
1 Correct answer
Unfortunately, I don't know AppleScript, nor do I have a Mac. However, with Javascript and scriptListener, you can record to scale layer styles. Does AppleScript work with scriptListener? Here is the javascript code that shows the scale styles:
var idImgS = charIDToTypeID( "ImgS" );
var desc764 = new ActionDescriptor();
var idWdth = charIDToTypeID( "Wdth" );
var idPrc = charIDToTypeID( "#Prc" );
desc764.putUnitDouble( idWdth, idPrc, 50.000000 );
var idscaleStyles = stringIDTo
...
Explore related tutorials & articles
Copy link to clipboard
Copied
Unfortunately, I don't know AppleScript, nor do I have a Mac. However, with Javascript and scriptListener, you can record to scale layer styles. Does AppleScript work with scriptListener? Here is the javascript code that shows the scale styles:
var idImgS = charIDToTypeID( "ImgS" );
var desc764 = new ActionDescriptor();
var idWdth = charIDToTypeID( "Wdth" );
var idPrc = charIDToTypeID( "#Prc" );
desc764.putUnitDouble( idWdth, idPrc, 50.000000 );
var idscaleStyles = stringIDToTypeID( "scaleStyles" );
desc764.putBoolean( idscaleStyles, true );//scale styles here
var idCnsP = charIDToTypeID( "CnsP" );
desc764.putBoolean( idCnsP, true );
var idIntr = charIDToTypeID( "Intr" );
var idIntp = charIDToTypeID( "Intp" );
var idbicubicSharper = stringIDToTypeID( "bicubicSharper" );
desc764.putEnumerated( idIntr, idIntp, idbicubicSharper );
executeAction( idImgS, desc764, DialogModes.NO );
Copy link to clipboard
Copied
Thanks Chuck,
I can run it from AppleScript and it works!
Better than nothing - but I hope that Adobe will listen and give us the Scale Styles option as a regular AppleScript parameter.
Copy link to clipboard
Copied
It is the same for JavaScript, this option is not available using the standard reference code.
Untested Idea: As AppleScript can call JS code, you would need to incorporate the desired chunk of JS code into your AS code. You can put the script "inline" or reference an external JS file.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
OK, minor progress...
I can't get a reference to an external js/jsx file to work.
I can get a simple single inline line of code to run:
tell application "Adobe Photoshop CC 2019"
activate
do javascript "alert('Hello Photoshop!');"
end tell
or something a little bit more exciting (select all layers menu command):
tell application "Adobe Photoshop CC 2019"
activate
do javascript "app.runMenuItem(stringIDToTypeID('selectAllLayers')); "
end tell
However my attempts at getting multi-line Script Listener recorded AM code to work have failed with AS compiler errors.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
you need to escape all quotes in the script.
as to path to external file then i couldn't make it work either.
tell application "Adobe Photoshop CC 2019"
set js to "var idImgS = charIDToTypeID( \"ImgS\" );
var desc764 = new ActionDescriptor();
var idWdth = charIDToTypeID( \"Wdth\" );
var idPrc = charIDToTypeID( \"#Prc\" );
desc764.putUnitDouble( idWdth, idPrc, 50.000000 );
var idscaleStyles = stringIDToTypeID( \"scaleStyles\" );
desc764.putBoolean( idscaleStyles, true );//scale styles here
var idCnsP = charIDToTypeID( \"CnsP\" );
desc764.putBoolean( idCnsP, true );
var idIntr = charIDToTypeID( \"Intr\" );
var idIntp = charIDToTypeID( \"Intp\" );
var idbicubicSharper = stringIDToTypeID( \"bicubicSharper\" );
desc764.putEnumerated( idIntr, idIntp, idbicubicSharper );
executeAction( idImgS, desc764, DialogModes.NO );"
--do javascript js
end tell
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
UPDATE: After some searching, I managed to get an externally referenced .jsx to run when called from an AppleScript!
tell application "Adobe Photoshop CC 2019"
activate
do javascript of file "/Users/username/Desktop/alert.jsx"
end tell
Or slightly different syntax to call the external script, here I have used different path delimiters, both types are valid and this makes no difference to the call:
tell application "Adobe Photoshop CC 2019"
activate
do javascript (file "Users:username:Desktop:alert.jsx")
end tell
Copy link to clipboard
Copied
Adding to this:
I found that the following would work for passing in arguments
function testFunc(t) {
alert('argument one: ' + t[0] + '\r' + 'argument two: ' + t[1]);
}
testFunc(arguments);
tell application id "com.adobe.Photoshop"
activate
do javascript of file "pathToFile" with arguments {"foo", "bar"}
end tell

