Skip to main content
Known Participant
December 15, 2021
질문

How to Bypass "JPEG Options" when saving JPG Files (under Photoshop v23.1)

  • December 15, 2021
  • 7 답변들
  • 6970 조회

I recently upgraded from Photoshop v 22.5.4 to v 23.1.

I used to open a few JPG files at a time, do some editing (cropping and adjustments) etc. and do "Close all".  At the "Close All" dialog box, I clicked "Yes" and checked "Apply to All". The purpose of doing this in a batch has been trying to avoid repeated keystrokes and mouse clicks.

I observed that some of the edited files coud be closed and saved (without further keystrokes) while some edited files would pop up "JPEG Options" dialog box.  When using v 22.5.4, there were less pop up, but when using v 23.1, all files would pop up the dialog box.  Thus, it defeated the purpose of "Apply to All".

In fact, I did nothing with the "JPEG Options" and just clicked the button "OK".  Is there any way to avoid popping up "JPEG Options" ?

 

 On the other hand, if I were to use "Quick Export as JPEG" or "Export As" under Export, the saved file would not contain the EXIF data (camera maker/model, lens, F-Stop, Exposure, ISO details...)  The Export Metadata under Export preferences only provide choice between "Copyright and Contact Info" and "None".  Am I missing somewhere to turn on "Export EXIF data" as well ?

 

7 답변

c.pfaffenbichler
Community Expert
Community Expert
May 3, 2023

jpg and psd/psb are different file formats, so I wonder how you arrived at those conclusions. 

Inspiring
May 3, 2023

Fabulous!!! 😄

Stephen Marsh
Community Expert
Community Expert
December 19, 2021

OK it appears that I needed to use a "switch" statement inside the while loop, my first use of switch! Anyway, here is a slightly refined v1.1 of the previous script, which accounts for "edge cases" of non-standard JPEG extension use:

 

/*
Save & Close All Open JPG Files Without Options Dialog.jsx
Stephen Marsh, v1.1 - 19 December 2021

This script presumes that all open files have been previously saved
*** TO DO - ADD CODE TO GRACEFULLY HANDLE UNSAVED OPEN FILES ***

How to Bypass "JPEG Options" when saving JPG Files (under Photoshop v23.1)
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-bypass-quot-jpeg-options-quot-when-saving-jpg-files-under-photoshop-v23-1/m-p/12597240
*/

#target photoshop

// CHECK FOR OPEN DOCS
if (app.documents.length) {

    // OPTIONAL CONFIRMATION
    if (!confirm("Save and close all previously saved JPG files?", false)) {
        //throw alert("Script cancelled!");
        throw null;
    }

    // LOOP OVER OPEN FILES
    while (app.documents.length > 0) {
        // USE SWITCH FOR DIFFERENT CONDITIONS
        var ext = app.activeDocument.name.match(/\.[^\.]+$/i).toString().toLowerCase();
        switch (ext) {
            case '.jpeg':
                jpeg();
            default:
                jpg();
        }
    }

    // END OF SCRIPT NOTIFICATION
    app.beep();

    // ALERT IF NO DOCS OPEN
} else {
    alert('You must have a document open!');
}

// SAVE ONLY MODIFIED .JPEG FILES USING EXISTING QUALITY LEVEL & OTHER OPTIONS
function jpeg() {

    // NON-STANDARD JPEG FILENAME EXTENSION IS PROBLEMATIC FOR SCRIPTING, THUS THIS HACK WORK-AROUND

    // FORCE AN EDIT...
    function uuid() {
        /* https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid */
        var chars = '0123456789abcdef'.split('');
        var uuid = [],
            rnd = Math.random,
            r;
        uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
        uuid[14] = '4'; // version 4
        for (var i = 0; i < 36; i++) {
            if (!uuid[i]) {
                r = 0 | rnd() * 16;
                uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r & 0xf];
            }
        }
        return uuid.join('');
    }

    app.activeDocument.artLayers.add().name = "randomLyrName = " + uuid();
    app.activeDocument.activeLayer.remove();

    if (app.activeDocument.path) {
        app.activeDocument.close(SaveOptions.SAVECHANGES);
    }
}

// SAVE MODIFIED OR UNMODIFIED .JPG FILES USING NEW QUALITY LEVEL & OTHER OPTIONS
function jpg() {
    var saveFileJPG = new File(app.activeDocument.path + '/' + app.activeDocument.name);
    saveJPG(saveFileJPG);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}

// JPEG SAVE OPTIONS
function saveJPG(saveFileJPG) {
    var jpgOptions = new JPEGSaveOptions();
    jpgOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgOptions.embedColorProfile = true;
    jpgOptions.matte = MatteType.NONE;
    jpgOptions.quality = 12;
    app.activeDocument.saveAs(saveFileJPG, jpgOptions, true, Extension.LOWERCASE);
}

 

 

Stephen Marsh
Community Expert
Community Expert
December 19, 2021

You can use the following script to save and close all open, previously saved files with a .jpg file extension. You can change the fixed quality value from 12 to something more appropriate.

 

/*
Save & Close All Open JPG Files Without Options Dialog.jsx
Stephen Marsh, v1.0 - 19 December 2021

This script presumes that all open files have a .jpg extension and have been previously saved, the script will stop if a file does not meet these conditions

How to Bypass "JPEG Options" when saving JPG Files (under Photoshop v23.1)
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-bypass-quot-jpeg-options-quot-when-saving-jpg-files-under-photoshop-v23-1/m-p/12597240
*/

#target photoshop

// CHECK FOR OPEN DOCS
if (app.documents.length) {
    
    // OPTIONAL CONFIRMATION
    if (!confirm("Save and close all previously saved JPG files?", false)) {
        //throw alert("Script cancelled!");
        throw null;
    }

    // LOOP OVER OPEN FILES
    while (app.documents.length > 0) {
        processOpenImages();
    }

    // END OF SCRIPT NOTIFICATION
    app.beep();

// ALERT IF NO DOCS OPEN
} else {
    alert('You must have a document open!');
}

// MAIN FUNCTION
function processOpenImages() {
    if (app.activeDocument.path && app.activeDocument.name.match(/\.jpg$/i)) {
        var saveFileJPG = new File(app.activeDocument.path + '/' + app.activeDocument.name);
        saveJPG(saveFileJPG);
        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }
}

// JPEG SAVE OPTIONS
function saveJPG(saveFileJPG) {
    var jpgOptions = new JPEGSaveOptions();
    jpgOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgOptions.embedColorProfile = true;
    jpgOptions.matte = MatteType.NONE;
    jpgOptions.quality = 12;
    app.activeDocument.saveAs(saveFileJPG, jpgOptions, true, Extension.LOWERCASE);
}

 

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

 

NOTE: I have been trying to add seamless options for gracefully handling files with the following criteria –

* Unsaved files (skip over and continue loop)

* Files without a .jpg extension (skip over and continue loop)

* Files with a non-standard .jpeg extension (skip over and continue loop or alert and handle  the save manually)

 

However, I keep hitting a brick wall where the script fails to continue looping over open files once one of these exceptions have been hit. Therefore the script will only work as intended if all open files have the .jpg extension. I thought that it was better to post the script as is, rather than waiting for a version that handled these exceptions when they may not be an issue.

 

Stephen Marsh
Community Expert
Community Expert
December 15, 2021

An action can record the desired JPEG save settings with a fixed save path location, just don't change the filename when recording. This is not useful unless you always open and save to the same location, such as the desktop. Actions have limitiations.

 

A script could be used to save all open documents to their original location, with their original name with your desired JPEG settings without a dialog. If they were not originally JPEG then a new file would be created, otherwise JPEG files would be overwritten.

martin.1작성자
Known Participant
December 15, 2021

As I replied to D Fosse above, I attempted to save all open documents by "File > Close" (which is supposed to same location and file type of the opened file) with recorded response to the dialog box, by recording Action steps.  When the Action is run, the dialog box still popped up. 

Stephen Marsh
Community Expert
Community Expert
December 15, 2021

The files that close without dialog were most likely previously saved by Photoshop and so the JPEG options are known. The files that bring up the dialog most likely were never saved from Photoshop, so the JPEG options are not known.

c.pfaffenbichler
Community Expert
Community Expert
December 15, 2021

Please provide meaningful information. 

 

How do you crop? »Delete Cropped Pixels« or not? 

If not then a jpg cannot be saved because it cannot contain any Layers except a Background Layer. 

martin.1작성자
Known Participant
December 15, 2021

Use the Crop Tool, with check box of "Delete Cropped Pixels" checked

D Fosse
Community Expert
Community Expert
May 3, 2023

I feel that there are key workflow behaviours that probably shouldn't be beholden to technique over-analysis. We're talking about quickly hitting the standard "save" shortcut on a JPG that is 99% of the time only then modified once further - maybe twice. Not enough on a hi-res JPG file to make any perceptible difference for either print nor screen to general consumers. From an interface point of view, for the standard CMD+S save action when applied to a JPG (the most widely used format) the user should simply be able to setup a preference that defaults it to the highest setting, or tick a box saying "save this setting always" rather than setup actions/shortcuts for such a rudimentary task that in my experience would never be the place that I let control any compression measures in the first place anyway. IMHO, YMMV, etc.


This is just a general observation, not specifically in response to Oli-G (although still relevant):

 

I am constantly surprised at how many people treat jpeg as an all-purpose working file format. Most of the time, it seems to me that these people simply don't realize the massive inherent limitations and problems of the jpeg format. If they did, they couldn't possibly ask for the things they do, could they?

 

So we try to educate. Yes, that's a nasty word; nobody likes to be told how to work. So we get nasty comments in return. That's OK, I can handle that.

 

But the truth is - jpeg is a highly specialized file format with one single highly specialized purpose: to crunch file size as much as possible without inflicting too much immediate damage. That's the only justification for using jpeg. Fast loading on the web; sending files by e-mail.

 

That's when you use jpeg, and in these cases it's a tradeoff. How small do you need the file to be, versus how much degradation can you accept under the circumstances. That's always a case-by-case tradeoff. A fixed setting, again, defeats the purpose.