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

Need a script to batch save image into multiple sizes

New Here ,
Jul 19, 2017 Jul 19, 2017

Hi,

Is there a script that can do the following?  I have my main hero image as a psd, or jpg that is 1600x1600.  I want to automate the batch image generation.  I'd like to click a button once and resave that image as 1200x1200, 1000x1000, 800x800, etc.  let's say i want 10 different sizes all at the same JPG quality.  Can I do this?

I know in Adobe Bridge CC, I can go Tools / Photoshop / Image Processor, and save out my image to different sizes.  i can even create an XML file that saves all the parameters I want.  But, I have to run this action 10 times for all my images.  Can it be done faster? 

2.5K
Translate
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

correct answers 1 Correct answer

Community Expert , Jul 19, 2017 Jul 19, 2017

Download and install Image Processor Pro Plug-in script. Once installed it will be accessible via menu File>Automate>Image Processor Pro... .

Translate
Adobe
Community Expert ,
Jul 19, 2017 Jul 19, 2017

Download and install Image Processor Pro Plug-in script. Once installed it will be accessible via menu File>Automate>Image Processor Pro... .

JJMack
Translate
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
New Here ,
Jul 20, 2017 Jul 20, 2017

Would this be the right one?  I downloaded the one for CS6/CC

Scripts Page

Translate
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
New Here ,
Jul 20, 2017 Jul 20, 2017

I found the pro plugin for CS6, but not the one for CC yet.  Do you know where to get it?

I tested it for CS6 and it does EXACTLY what we want.  One click script and generate multiple images with varying dimensions, resolution, format, etc.  Thanks!!

Translate
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
Community Expert ,
Jul 20, 2017 Jul 20, 2017

ps-scripts - Browse /Image Processor Pro/v3_2 betas at SourceForge.net

I have installed it in all Photoshop version CS6  and above

JJMack
Translate
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
New Here ,
Jul 20, 2017 Jul 20, 2017

All good now.  i had to do a manual install for some reason.  Thanks again!

Translate
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
Participant ,
Apr 08, 2023 Apr 08, 2023
LATEST

FYI I ended up going with this script which suited my needs better for the resizing (ie. filling the entire canvas so no "white space" exists, rather than the resize on the Image Processor Pro which fits the artwork to the canvas on the tallest side and can leave "white space"). If Image Processor Pro ever adds "Fill to Canvas" as an extra option, then I'd go with it, but in the meantime ...

I am sure there are more efficient ways for doing the script, and would like to hear from anyone interested in improving it.

I run the script, which asks for a saved artwork image; then creates 7 x Photoshop documents in common wall art sizes. It names the documents the same as artwork image, with size suffix. Artwork image is resized to fill the canvases, middle centre. Script ends with 7 docs open in Photoshop, because after this script finishes, only if necessary, I manually reposition artwork in each document to ensure artwork looks OK.

FYI ONLY (not part of this script): To save the finished images, I run Photoshop > File > Scripts > Image Processor, then close all Photoshop > File > Close All (check "Apply to All")

 

// excuse the over-commenting

main();
function main() {
    // Select the artwork image and location
    var myFolderLocation = Folder.selectDialog ("Where is the folder of the base image? - find it, then select 'Open'");
    var aFolder = myFolderLocation; // change the path as needed
    var theFile = aFolder.openDlg("Select the base image file: - find it, then select 'Open'","*.jpg;*.png;*.tif");
    // Filename prefix without extension
    var theFilenamePrefix = theFile.name.replace(/\.[^\.]+$/, '');
    // DPI
    dpi = 300;

    // 11x14 inches, 3300x4200 pixels ____________________________________________
    var name11x14 = theFilenamePrefix + "_11x14inches";
    var width11x14 = 3300; // width in pixels
    var height11x14 = 4200; // height in pixels
    app.documents.add (UnitValue (width11x14, 'PX'), UnitValue(height11x14, 'PX'),
        dpi, name11x14, NewDocumentMode.RGB);
        placeSmartObject(theFile);
    fillArtworkToCanvas();

    // 20x20 inches, 6000x6000 pixels ____________________________________________
    var name20x20 = theFilenamePrefix + "_20x20inches";
    var width20x20 = 6000; // width in pixels
    var height20x20 = 6000; // height in pixels
    app.documents.add (UnitValue (width20x20, 'PX'), UnitValue(height20x20, 'PX'),
        dpi, name20x20, NewDocumentMode.RGB);
    placeSmartObject(theFile);
    fillArtworkToCanvas();

    // 20x28 inches, 6000x8400 pixels ____________________________________________
    var name20x28 = theFilenamePrefix + "_20x28inches";
    var width20x28 = 6000; // width in pixels
    var height20x28 = 8400; // height in pixels
    app.documents.add (UnitValue (width20x28, 'PX'), UnitValue(height20x28, 'PX'),
        dpi, name20x28, NewDocumentMode.RGB);
    placeSmartObject(theFile);
    fillArtworkToCanvas();

    // 24x30 inches, 7200x9000 pixels ____________________________________________
    var name24x30 = theFilenamePrefix + "_24x30inches";
    var width24x30 = 7200; // width in pixels
    var height24x30 = 9000; // height in pixels
    app.documents.add (UnitValue (width24x30, 'PX'), UnitValue(height24x30, 'PX'),
        dpi, name24x30, NewDocumentMode.RGB);
    placeSmartObject(theFile);
    fillArtworkToCanvas();

    // 24x32 inches, 7200x9600 pixels ____________________________________________
    var name24x32 = theFilenamePrefix + "_24x32inches";
    var width24x32 = 7200; // width in pixels
    var height24x32 = 9600; // height in pixels
    app.documents.add (UnitValue (width24x32, 'PX'), UnitValue(height24x32, 'PX'),
        dpi, name24x32, NewDocumentMode.RGB);
    placeSmartObject(theFile);
    fillArtworkToCanvas();

    // 24x36 inches, 7200x10800 pixels ____________________________________________
    var name24x36 = theFilenamePrefix + "_24x36inches";
    var width24x36 = 7200; // width in pixels
    var height24x36 = 10800; // height in pixels
    app.documents.add (UnitValue (width24x36, 'PX'), UnitValue(height24x36, 'PX'),
        dpi, name24x36, NewDocumentMode.RGB);
    placeSmartObject(theFile);
    fillArtworkToCanvas();

    // A1, 594x841mm nearest approx in Photoshop, 7016x9933 pixels best it can do____
    // (Photoshop can only do whole pixels, not part pixels)
    var nameA1 = theFilenamePrefix + "_A1";
    var widthA1 = 7016; // width in pixels
    var heightA1 = 9933; // height in pixels
    app.documents.add (UnitValue (widthA1, 'PX'), UnitValue(heightA1, 'PX'),
        dpi, nameA1, NewDocumentMode.RGB);
    placeSmartObject(theFile);
    fillArtworkToCanvas();

//======================================================
// FUNCTIONS

// -----------------------------------------
// Place artwork as smart object function
// -----------------------------------------
// Ref: Michael L Hale https://community.adobe.com/t5/photoshop-ecosystem-discussions/place-image-into-layer/m-p/3937893
function placeSmartObject(theFile){ // file object or path as strng
    try {
        var desc = new ActionDescriptor();
            desc.putPath( charIDToTypeID( "null" ), new File( theFile ) );
            desc.putEnumerated( charIDToTypeID( "FTcs" ), charIDToTypeID( "QCSt" ),charIDToTypeID( "Qcsa" ));
            desc.putUnitDouble( charIDToTypeID( "Wdth" ),charIDToTypeID( "#Prc" ), 100 );
            desc.putUnitDouble( charIDToTypeID( "Hght" ), charIDToTypeID( "#Prc" ), 100 );
            desc.putUnitDouble( charIDToTypeID( "Angl" ), charIDToTypeID( "#Ang" ), 0 );
            desc.putBoolean( charIDToTypeID( "Lnkd" ), false ); // place embedded
            executeAction( charIDToTypeID( "Plc " ), desc, DialogModes.NO );
            activeDocument.activeLayer.resize(100, 100, AnchorPosition.MIDDLECENTER);
            activeDocument.revealAll();
            return true;
        } catch (e) {
            return false;
        }
    };

// -----------------------------------------
// Fill artwork to canvas function
// -----------------------------------------
// Ref. JJ Mack https://community.adobe.com/t5/photoshop-ecosystem-discussions/scale-layer-to-current-canvas-size-photoshop/td-p/5217315/page/2
function fillArtworkToCanvas() {
    var imageLayerWidth = app.activeDocument.width.as('px');  
    var imageLayerHeight = app.activeDocument.height.as('px');  
    var bounds = app.activeDocument.activeLayer.bounds;  
    var LWidth = bounds[2].as('px')-bounds[0].as('px');  
    var LHeight = bounds[3].as('px')-bounds[1].as('px'); 

    var userResampleMethod = app.preferences.interpolation;  // Save interpolation settings  
    app.preferences.interpolation = ResampleMethod.BICUBIC; // resample interpolation bicubic  

    if (LWidth / LHeight < imageLayerWidth / imageLayerHeight ) { // if the canvas area Aspect Ratio is less than the image layer Aspect Ratio   
    
    var percentageChange = ((imageLayerWidth / LWidth) * 100.25);  // Resize to canvas area width, plus extra allowance
    activeDocument.activeLayer.resize(percentageChange, percentageChange, AnchorPosition.MIDDLECENTER);  
    }  

    else {
    
    var percentageChange = ((imageLayerHeight / LHeight) * 100.25); // Resize to canvas area height, plus extra allowance 
    
    // resize - pass in horizontal, vertical, anchor in the parameters
    activeDocument.activeLayer.resize(percentageChange, percentageChange, AnchorPosition.MIDDLECENTER);  
    }
    
    // FYI Anchor positions can be:
        // BOTTOMCENTER, BOTTOMLEFT, BOTTOMRIGHT
        // MIDDLECENTER, MIDDLELEFT, MIDDLERIGHT
        // TOPCENTER, TOPLEFT, TOPRIGHT
        
    app.preferences.interpolation = userResampleMethod; // Reset interpolation setting  
    app.activeDocument.selection.selectAll();

    // ALIGN call from function below
    align('AdCH'); align('AdCV');
    //align('AdRg');
    app.activeDocument.selection.deselect();

    // FYI
        /* 
        AdLf = Align Left
        AdRg = Align Right
        AdCH = Align Centre Horizontal
        AdTp = Align Top
        AdBt = Align Bottom
        AdCV = Align Centre Vertical
        */

    } // end of function fillArtworkToCanvas()

// -----------------------------------------
// Align layers to selection function
// -----------------------------------------
// Ref: SuperMerlin https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-resize-an-image-layer-to-the-same-size-as-the-width-of-the-document-respecting-its-aspect/m-p/8652034
function align(method) {

    var desc = new ActionDescriptor();
    var ref = new ActionReference();
    
    ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
    desc.putReference( charIDToTypeID( "null" ), ref );
    desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "ADSt" ), charIDToTypeID( method ) );
    // FYI charIDToTypeID is a Method with a parameter type of string, returns a number
    
    try {
    
    executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );
    // FYI 'Algn' is an Event ID Code
        
    } catch(e){}
} // end of function align(method)

        
} // end of main function

 

Translate
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