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 답변들
  • 6988 조회

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

Inspiring
May 3, 2023
quote

 In 15+ years neither myself nor anyone has had any use-case to reduce quality


By @Oli-G

 

To be clear, a jpeg will always reduce quality, even at quality 12. Jpeg compression is always destructive, cumulative and non-reversible. There is no such thing as "maximum quality" with jpeg.

 

When a jpeg is opened, it is decompressed back to full native size (but not exactly the same state). Resaving it will initiate the compression algorithm from scratch every time. It doesn't "remember" the last compression - except that the compression level may be recorded in metadata and so come up in the dialog automatically.

 

Conventional wisdom is that anything above 8 - 10 is basically wasted and defeats the whole purpose of jpeg. The file size will be considerably higher for no direct visual improvement. The whole purpose of jpeg is to reduce storage and transfer size, so you may as well maximize the payoff considering it will be degraded in any case.

 

The success of jpeg is precisely because the immediate visual impact is very small. The degradation doesn't really show until repeated resaves - but then the file rapidly falls apart. Save once only and you'll be fine.

 

 


100% but I think i've not conveyed my point properly. This is about reducing unnecessary clicks in a time when data-storage is less of an issue to warrant splitting hairs exerting control of a compression algorithm. Most users know the JPG destruction thing, but most use-cases see re-saves only happening a couple of times in a majority of applications. In a career spanning design, advertising, and photography over 20 years, the overwhelming majority use-case of JPG manipulation post-creation is opening, modifying, and saving permanently. The interface-hurdle like this that a user cant subvert by setting a preference to 12 (or any number you pick - if 7 is your flavour then so be it) is obfuscated, unnecessary, un user-focused functionality that has not kept up wth the times.

 

The software should let me set a global preference for the quality I want to use in my line of work, and have it apply each and every time I press CMD+S, so that i'm not piddling around waiting for a redundant dialogue to repeatedly be interacted with.