Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Request: Add Scale Styles option to "resize image" command in AppleScript

Community Expert ,
Sep 27, 2019 Sep 27, 2019

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

TOPICS
Actions and scripting
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 27, 2019 Sep 27, 2019

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
...
Translate
Community Expert ,
Sep 27, 2019 Sep 27, 2019

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 );
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2019 Sep 27, 2019

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2019 Sep 27, 2019

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2019 Sep 27, 2019
Thanks - yes I tried it and I can run it from AppleScript
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2019 Sep 27, 2019
Can you please share your working AS/JS code? As you will see from below, I have been trying to work this out for you, with only limited success...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2019 Sep 27, 2019

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.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2019 Sep 27, 2019
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2019 Sep 27, 2019
umm i don't know what's up with the Reply function on this forum... I'll try to repost.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2019 Sep 27, 2019


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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2019 Sep 27, 2019
P.S. oops obviously uncomment 'do javascript js' in the end
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2019 Sep 27, 2019
Team effort! Thanks Chuck for the ScriptListener AM code! Thank you leo for letting me know about escaping the quotes (Despite using a Mac most of the time, I know very little about AS).
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2020 Jan 31, 2020

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

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 20, 2023 May 20, 2023
LATEST

Adding to this:

I found that the following would work for passing in arguments

 
JavaScript

 

function testFunc(t) {
 alert('argument one: ' + t[0] + '\r' + 'argument two: ' + t[1]);
}

testFunc(arguments);

 

 
AppleScript

 

tell application id "com.adobe.Photoshop"
activate
do javascript of file "pathToFile" with arguments {"foo", "bar"}
end tell

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines