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

Saving JPEGs Via an Action

Contributor ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

I have an action that saves JPEG files. Basically, it changes to 8-bit mode, does a Save A Copy, choose file type JPEG and Saves the file. The first issue is that in PS 26.1, the folder to save to is always the same folder as that used when the action was created. I believe previously in earlier PS versions, it always brought up the most recently saved folder. If I am working in a specific folder, adjust an image as desired, save a PSD file, and then subsequently click my action to Save As JPEG, the folder where JPEG will be saved is always the same, which is very annoying because have to navigate to the current folder. You can imaging if I have multiple images to edit, this is bothersome because it takes extra time. This could be a bug that did not occur in 26.0 or previous versions. Secondly, I've asked for this before, but please change the code to always save to the same folder where the saved PSD file is located. I don't want to navigate to a different folder ever when saving a JPEG file, in an action, after having opened or saved the image to a PSD file. Navigating is unnecessary if the code were revised to do as I requested.

Idea No status
TOPICS
Actions and scripting , Windows

Views

204

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
15 Comments
Community Expert ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

  • In the action, include steps to make the file fully compliant with the jpeg specification (8 bit, flattened, no alpha channel*). Then you can use Save instead of Save A Copy.
  • When recording the action, make sure the file name and path are not highlighted and not recorded in the action. Just hit Save.
  • In PS preferences, make sure "Save to original folder" is checked.

 

I haven't tested this, but if this doesn't work nothing will. Then you need a script.

 

*to remove alpha channels, you need to call this very simple script, which can also be recorded as "insert menu item":

activeDocument.channels.removeAll();

 

Votes

Translate

Translate

Report

Report
Community Expert ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

Actions always have recorded the full local computer path to the file. What is optional is to include or exclude the filename. File > Automate > Batch can override the action save as location, but if using the action outside of Batch then it uses the recorded path to the directory/folder used when recording the action. The other alternative is to insert the menu item into the action, rather than recording the path. If the path is recorded, then the modal control to the left of the action step can be activated to make the save step interactive.

Votes

Translate

Translate

Report

Report
Community Expert ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

Yeah, I just tested it and it doesn't work. Since you're saving to a different file format, it has to be Save As, not Save, and the path has to be specified.

Votes

Translate

Translate

Report

Report
Contributor ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

D Fosse, thank you for the suggestion, but that did not work. First I had to use Save As instead of Save because otherwise it would save a .PSD file. In Save As, I select type JPEG from the dropdown. I also had to leave the filename because without it, the saving has no idea what to name the file and does nothing. I did clear out the folder information before saving. When I finished the new action, I looked at the sub-action labeled Save. One of the line items is "In" and it recorded the folder where the JPEG was saved. Unfortunately, when I go to another directory, launch a different .PSD file and then try to execute the action, the "In" remains as it was when the action was recorded.

Votes

Translate

Translate

Report

Report
Contributor ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

Stephen_A thank you for your suggestion. I am not sure what you are talking about. When the action is recorded, I click on the menu item Save As. I do have a ??? set to be interactive during the saving step so that I can select different folders and change file names. The issue is my having to select the save to folder each time I run the action, which is a pain. If Photoshop could some how populate the Save As dialog with the original folder where the .PSD file is located, it would save a ton of work.

Votes

Translate

Translate

Report

Report
Contributor ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

I am beginning to think that when I click on Save a Copy while recording an action, Photoshop should omit the "In" paramter. Perahaps that would solve the problem. Adobe should automatically populate the folder in the Save dialog with the same folder where the .PSD file is located. Just a thought. Adobe, kindly ask your software developers to try this.

Votes

Translate

Translate

Report

Report
Community Expert ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

quote

Stephen_A thank you for your suggestion. I am not sure what you are talking about.


By @Ken Curtis

 

Actions either record the full local path, or the full local path + filename of open doc when recording.

 

atn.png

 

Modal control for interactive playback:

 

2024-05-18_19-05-50.png

Votes

Translate

Translate

Report

Report
Community Expert ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

quote

I am beginning to think that when I click on Save a Copy while recording an action, Photoshop should omit the "In" paramter. Perahaps that would solve the problem. Adobe should automatically populate the folder in the Save dialog with the same folder where the .PSD file is located. Just a thought. Adobe, kindly ask your software developers to try this.


By @Ken Curtis

 

 

As @D Fosse wrote, the alternative is a script to perform the save action to the same folder as the open file. Perhaps something like this:

 

/*
JPEG Save As a Copy to Source Directory.jsx
Stephen Marsh
v1.0 - 26th November 2024
https://community.adobe.com/t5/photoshop-ecosystem-ideas/saving-jpegs-via-an-action/idc-p/15002989
*/

#target photoshop

if (app.documents.length) {

    // Check if the bit depth is 32 bpc
    if (app.activeDocument.bitsPerChannel == BitsPerChannelType.THIRTYTWO) {
        throw alert("Script cancelled!\rThe image mode is 32 bpc, tone mapping to 8 or 16 bpc is required before continuing.");
    }

    var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');

    try {
        // Use the previously saved path
        var docPath = app.activeDocument.path;
    } catch (e) {
        // If unsaved, prompt for save directory
        var docPath = new Folder.selectDialog("Unsaved base file, select the output folder:");
    }

    // File Path & Naming
    var nameAndPath = new File(docPath + '/' + docName + '.jpg');

    if (nameAndPath.exists) {
        // true = 'No' as default active button
        if (!confirm("File exists, overwrite: Yes or No?", true))
            // throw alert("Script cancelled!");
            throw null;
    }

    saveJPEG(nameAndPath);

} else {
    alert("You must have a document open!");
}

function saveJPEG(saveDetails) {
    var jpgSaveOptions = new JPEGSaveOptions();
    jpgSaveOptions.embedColorProfile = true;
    jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgSaveOptions.matte = MatteType.NONE;
    jpgSaveOptions.quality = 10;
    app.activeDocument.saveAs(saveDetails, jpgSaveOptions, true, Extension.LOWERCASE); // true for save a copy
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

Votes

Translate

Translate

Report

Report
Community Expert ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

"I also had to leave the filename because without it, the saving has no idea what to name the file and does nothing."

 

Have you tested it, or is that just your opinion? Or do you misunderstand? Do not delete the file name when recording; just leave it as is. It will use the file name to save the file; it can be saved as "untitled" if you created the file without naming it. Please test it.

Votes

Translate

Translate

Report

Report
Contributor ,
Nov 26, 2024 Nov 26, 2024

Copy link to clipboard

Copied

Thank you Stephan_A_. Let me try to clarify what I am trying to do in hopes that this explanation will be clearer. I work on an image in 16 bits and save it as a .PSD file. Nothing magic there and it works fine. Next I want to save the same image as JPEG file so that both the .PSD and .JPG files are in the same folder. I wrote an action to change the mode to 8 bits, save the file as a JPEG (this is the problem part) and then return to my previous step.

 

SaveAsJPEGAction.jpg

 

The first figure shows the action expanded. The red arrow points to the "In" parameter, which I interpret to mean "Save the file IN this folder." The "In" parameter value is always the same whenever I run the action. That value was recorded when I recorded the action. What I really want is for the "In" value to be the folder where the .PSD file is located. The second figure shows my PS preferences. Notice that the "Save As to Original Folder" is checked. BTW, checking the Enable legacy Save As has the same problem.

 

FileSavingOptions.jpg

 

I should not have to write a script. It should just work. It always did before Photoshop changed the requirement to save JPEGs using the Save As Copy a few versions previous. The Photoshop developers should be able to examine the preference of saving to the original folder and use that value for the "In" parameter, if they even need an "In" parameter.

 

I hope this helps.

Votes

Translate

Translate

Report

Report
Contributor ,
Nov 26, 2024 Nov 26, 2024

Copy link to clipboard

Copied

Thanks Bojan. I always leave the file name in the Save dialog. If the .PSD file were named MyImage.psd then the JPEG file should be named MyImage.jpg. Untitled is certainly not what I want to do, because then I would need to manually rename it as I really want it to be.

Votes

Translate

Translate

Report

Report
Community Expert ,
Nov 26, 2024 Nov 26, 2024

Copy link to clipboard

Copied

quote

The first figure shows the action expanded. The red arrow points to the "In" parameter, which I interpret to mean "Save the file INthis folder." The "In" parameter value is always the same whenever I run the action. That value was recorded when I recorded the action. What I really want is for the "In" value to be the folder where the .PSD file is located. The second figure shows my PS preferences. Notice that the "Save As to Original Folder" is checked. BTW, checking the Enable legacy Save As has the same problem.

 

 

The "Save As to Original Folder" is only for manual saves, not for recorded actions, where the path from the local computer recording the action is always used.

 

quote

I should not have to write a script. It should just work. It always did before Photoshop changed the requirement to save JPEGs using the Save As Copy a few versions previous. The Photoshop developers should be able to examine the preference of saving to the original folder and use that value for the "In" parameter, if they even need an "In" parameter.


By @Ken Curtis

 

 

I tested in v2019 which pre-dates the "Legacy Save As" and nothing has changed. Actions have always recorded the "in" local absolute path and they always use that when run, except for File > Automate > Batch which offers the ability to override the recorded action save command.

 

I understand what you want, which is why I offered a script. Scripts offer more possibilities than actions. I agree that actions should offer more refined and flexible features.

 

I have voted on your idea (feature request).

Votes

Translate

Translate

Report

Report
Contributor ,
Nov 27, 2024 Nov 27, 2024

Copy link to clipboard

Copied

Stephan_A, I have never used a script before in Adobe. I taught myself Javascript after retiring in 2008 so I could create custom websites, but have not used Javascript for many years now. Nevertheless, I was able to understand your script and will give it a try. I have to figure out how to install it into PS. The document you referenced below your script will be my guide. I will need a few days until I can get to it because of the holidays. Thank you for taking the time to write it. Ken

Votes

Translate

Translate

Report

Report
Contributor ,
Nov 27, 2024 Nov 27, 2024

Copy link to clipboard

Copied

Stephen_A_Marsh I added your script to Photoshop and created a new action to Save As JPEG using your script.

 

Revised Save As Copy Action.jpg

Your script worked very well, and I am a much happier camper.

I wonder if you would take a second look and revise the code. My reason is because there are occasionally times when I want save the JPEG file with a different file name. Example: I have a .PSD file with the name BoatInWater.psd. I want to save the original color file as a JPEG into BoatInWater.jpg. After doing that, I may, as an example, want to add a black and white adjustment layer to the image. Rather than overwriting the BoatInWater.jpg file, I want to save the file as BoatInWater_B&W.jpg. Is there a way to modify your code to give me an opportunity to change the file name? Maybe the folder too.

I appreciate what you have done so far. It is definitely a help and saves a lot of navigating (and extra keystrokes and mouse clicks) when I do want to save the image as a JPEG with the original base file name.

 

Votes

Translate

Translate

Report

Report
Community Expert ,
Nov 27, 2024 Nov 27, 2024

Copy link to clipboard

Copied

LATEST

@Ken Curtis 

 

The code was designed for "headless" operation, although it can be modified, perhaps one of these scripts that I previously wrote may be a good starting point for interactivity:

 

Votes

Translate

Translate

Report

Report