Save As JPEG in AppleScript

Explorer ,
Feb 23, 2014 Feb 23, 2014

Copy link to clipboard

Copied

Trying to Save a PSD file as JPEG using the script from the Adobe scripting documentation.

The following code opens the standard Save As dialog box rather than simply saving the file, I am missing something ... but what??!

tell application "Adobe Photoshop CC"

 

          set theDocument to current document

 

          set myFile to "Macintosh HD:Users:peterrhawkes:Desktop:MH.jpg"

          set myOptions to ¬

                    {class:JPEG save options, embed color profile:true, quality:12} ¬

 

  save theDocument in file myFile as JPEG with options ¬

  myOptions appending no extension without copying

 

end tell

TOPICS
Actions and scripting

Views

2.7K

Likes

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
Adobe Community Professional ,
Feb 26, 2014 Feb 26, 2014

Copy link to clipboard

Copied

I think pretty much only one of the »top participants« here bothered with AppleScript and I’m not sure he still drops by regularly.

Maybe you should consider switching to JavaScript for automating Photoshop tasks.

Likes

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 ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

hi

there are some good reasons to use applescript – not only photoshop is working on a mac.

with applescript it is possible to build automation tasks over the whole system including various applications.

have fun.

Likes

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
Adobe Community Professional ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

there are some good reasons to use applescript
with applescript it is possible to build automation tasks over the whole system including various applications.

I’d call that one reason, so the plural "reasons" might be considered contestable.

Likes

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 ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

another one is: be yourselfdon't do anything just because everyone else is doing it or as well known think different!

Likes

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
Adobe Community Professional ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

Your AppleScript savvy is certainly welcome as I have the impression the one "regular" with significant AS experience is not dropping by much anymore.

don't do anything just because everyone else is doing it

I see no moral preferability to either AS or JavaScript so doing it the same way as most others does not seem to be detestable in itself and the number of people using them does not proof or disproof their respective qualities.

Many people who come to this Forum with their automation problems are beginners at Scripting and need help – help that in the case of JavaScript a certain number of other contributors may be able to provide and in the case of AppleScript a (based on my observations) smaller number of other contributors may be able to provide.

There might be benefits in learning and utilising as big a number of languages as possible, but for many people that may not be the immediately preferable option.

Each person coming freshly to this matter has to make their own decisions but should one really base the decision on which language to use/learn on some individualistic or romantic imagery instead of trying to weigh the pros and cons?

Likes

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
Guru ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

I do check in from time to time...

Trying to get self-employment off the ground. So less time to post here.

I can't help because I'm not on CC yet.

I did find more difference between app

Versions when AppleScripting.

At a glance the syntax looks ok...

PS now prefers file paths as strings

And not alias...

Looks like the next Apple OS will have

JavaScript added to its apps...

Sent from my iPhone

Likes

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
Adobe Community Professional ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

I do check in from time to time...

I hope my observation did not come off as reproachful or disrespectful.

Best of luck and have a good weekend!

Pfaffenbichler

Likes

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
Guru ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

No not all... I do get updates from the forums.

Most of the time I can rest knowing others

will respond before I have the time to.

I would say that I had more problems with AppleScript over ExtendScript.

I do understand the OPs reasons though.

As of CS5 I did have issues just getting a

reference to the current document.

Work on script first run in SE then after

that broken until relaunch...

Sent from my iPhone

Likes

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 ,
Jul 04, 2014 Jul 04, 2014

Copy link to clipboard

Copied

hi peter

I faced a general error with no further information in photoshop cc when I used your code for a try, even there was no save as dialog box.

for me it helped to declare the destination path as string.

tell application "Adobe Photoshop CC"

  set theDocument to current document

  set myFile to "System:Users:imac7:Desktop:MH.jpg" as string

  set myOptions to ¬

  {class:JPEG save options, embed color profile:true, quality:12} ¬

  save theDocument in file myFile as JPEG with options ¬

  myOptions appending no extension without copying

end tell

hope this helps.

have fun.

Likes

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 ,
Apr 29, 2021 Apr 29, 2021

Copy link to clipboard

Copied

LATEST

found this old thread when I was having the same issue.

 

My solution was to add a line to flatten the current document first.

 

In my case, I was opening PDFs and saving them as JPEGs (& TIFFs). So the current documents in my case always had a layer (just a "Layer 1," not a flattened "Background.")

 

I noticed in the Save dialog that invariably popped up the PS warning that the file would have to be "saved as a copy" that you get when PS is saving a file with features (layers) that the format doesn't support.

 

just flatten it first.

 

flatten current document

save current document in [/pathtoyourfile/filename.jpg] as JPEG with options ¬

{class:JPEG save options, embed color profile:true, matte:none, quality:12}

Likes

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