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

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

Community Expert ,
Sep 27, 2019 Sep 27, 2019

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

TOPICS
Actions and scripting

Views

1.8K

Translate

Translate

Report

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
...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 27, 2019 Sep 27, 2019

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 );

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thanks - yes I tried it and I can run it from AppleScript

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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...

Votes

Translate

Translate

Report

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

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.

 

 

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

umm i don't know what's up with the Reply function on this forum... I'll try to repost.

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

P.S. oops obviously uncomment 'do javascript js' in the end

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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).

Votes

Translate

Translate

Report

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

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

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

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