Skip to main content
Known Participant
February 23, 2014
Question

Save As JPEG in AppleScript

  • February 23, 2014
  • 3 replies
  • 4579 views

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

This topic has been closed for replies.

3 replies

New Participant
April 29, 2021

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}

chris breu
Participating Frequently
July 4, 2014

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.

c.pfaffenbichler
Adobe Expert
February 26, 2014

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.

chris breu
Participating Frequently
July 4, 2014

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.

c.pfaffenbichler
Adobe Expert
July 4, 2014
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.