2

I work with product images for an online retail site. Each product image needs to have a .jpg copy and .png copy. Currently, I just export once as .jpg and then export again as .png. This is both time-consuming and I often forget one of the file types. Is it possible to have a quick export that creates both filetypes simultaneously?

I've read about batch processing and photoshop actions, but I can't seem to get them to work. I record this action: File > Export > Export As > "Select .jpg" > Export > "Set Filename & Location (Repeat for .png). This, however, doesn't seem to actually record any action.

I've also recorded: File > Save As > "Name File, Select Location, Format: .jpg" > Save (Repeat for .png). This works in that I can use it to simultaneously save as .jpg and .png, but it doesn't allow me to change the filename or location.

8
  • You could record an Action to do that. See Creating Photoshop Actions
    – Billy Kerr
    Mar 26, 2021 at 16:19
  • Batch processing means to run the same action for a range of files. That action could save png and jpg.
    – Wolff
    Mar 26, 2021 at 16:38
  • @BillyKerr I think you're on to something. I tried recording an action, but when I trigger it nothing happens. I record: File > Export > Export As > Select .jpg > Export > Set Filename and Location. It doesn't seem to record any of that.
    – wheel58m
    Mar 26, 2021 at 17:20
  • Don't use Export As. It's not recordable in Actions. Use File > Save As instead.
    – Billy Kerr
    Mar 26, 2021 at 17:25
  • @BillyKerr this action works as expected, but doesn't allow me to change the filename or location, it saves as the recorded name and location.
    – wheel58m
    Mar 26, 2021 at 17:57

1 Answer 1

3

After doing some research I was able to develop my first Photoshop script to do the trick. This script might be a little dirty (I'm new to JavaScript).

The script does the following:

  1. Ask the User for a filename.
  2. Ask the User to select a save folder.
  3. Save as .jpg
  4. Save as .png
  5. Alert the User that the operation is completed.
// ASK FOR FILENAME
var filename = prompt("Type in Filename", "untiled").replace(/\.[^\.]+$/, '');
// SELECT A SAVE LOCATION
var filepath = Folder.selectDialog("Choose a Save Location");


saveJPG(filename, filepath); // Run "Save as JPG" Function
savePNG(filename, filepath); // Run "Save as PNG" Function
alert("Complete"); // Alert the User that the Operation is Complete

// SAVE AS JPG
function saveJPG(filename, filepath) {
    var fileJPG = File(filepath + "/" + filename + ".jpg"); // Create .jpg file

    var jpgOptions = new JPEGSaveOptions;
    jpgOptions.quality = 9;
    jpgOptions.formatOptions = FormatOptions.STANDARDBASELINE;

    // Save as .jpg
    activeDocument.saveAs(fileJPG, jpgOptions, true, Extension.LOWERCASE);
};

// SAVE AS PNG
function savePNG(filename, filepath) {
    var filePNG = File(filepath + "/" + filename + ".png"); // Create .png file

    var pngOptions = new PNGSaveOptions;
    pngOptions.compression = 9;

    // Save as .png
    activeDocument.saveAs(filePNG, pngOptions, true, Extension.LOWERCASE);
};

To get a keyboard shortcut to run the script, I simply recorded a Photoshop action.

2
  • Hi I have a question that can we modify to keep original filenames?
    – Daniel
    Aug 28, 2021 at 18:16
  • 1
    @Daniel, I've made a similar script that places the current doc name into the prompt: app.activeDocument.name.split('.')[0]. The primary file format is PSD and the secondary file format is JPEG, but with both of these scripts you should be able to modify either to fit your needs.
    – Joonas
    Aug 30, 2021 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.