Re: The following script will resize the canvas to square bas... (2025)

Re: The following script will resize the canvas to square bas... (1)

New Here ,

/t5/photoshop-ecosystem-discussions/batch-resizing-photos-of-different-dimensions/td-p/11074302 Apr 23, 2020 Apr 23, 2020

Copy link to clipboard

Copied

I have hundreds of photos that I want to all be square in order to look more clean when presented on a website. These photos have different dimensions, some more square and some more rectangular. I've been creating a new document of the correct square ppi dimensions and have been just importing one photo at a time onto this blank template. Photoshop automatically fits the image perfectly so there is proper white space around the photo just as I need. However like I said there are hundreds of photos. Is there a way to do this in a batch action? I've looked into batch resizing but that seems like it wouldn't help as these photos are all different sizes and I need to add that white square as their background. So it's not so much of a resizing issue, but creating many new documents of the same size all at once and placing all of these photos on the new documents individually. If this isn't possible, that's fine I just was looking for a definite answer as to if I can do this or not because I cannot seem to find an answer online anywhere.

TOPICS

Actions and scripting

Views

2.6K

Translate

Translate

Report

Report

  • Follow
  • Report

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Re: The following script will resize the canvas to square bas... (2)

    Re: The following script will resize the canvas to square bas... (3)

    Explore related tutorials & articles

    Re: The following script will resize the canvas to square bas... (4) 9 Replies 9

    Jump to latest reply

    Re: The following script will resize the canvas to square bas... (7) Re: The following script will resize the canvas to square bas... (8)

    Community Expert ,

    /t5/photoshop-ecosystem-discussions/batch-resizing-photos-of-different-dimensions/m-p/11074348#M324939 Apr 23, 2020 Apr 23, 2020

    Copy link to clipboard

    Copied

    Have a look at the Photoshop Image Processor – File > Scripts > Image Processor

    Votes

    Upvote

    Translate

    Translate

    Report

    Report

    • Follow
    • Report

    Community guidelines

    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

    Re: The following script will resize the canvas to square bas... (9)

    Re: The following script will resize the canvas to square bas... (10) Re: The following script will resize the canvas to square bas... (11)

    Community Expert ,

    /t5/photoshop-ecosystem-discussions/batch-resizing-photos-of-different-dimensions/m-p/11076155#M325117 Apr 24, 2020 Apr 24, 2020

    Copy link to clipboard

    Copied

    In Response To Derek Cross

    Image Processor will not change a images aspect ratio to square. The image's aspect ration is preserved. The image is resized via interpolation fit with within the square size you set.

    JJMack

    Votes

    Upvote

    Translate

    Translate

    Report

    Report

    • Follow
    • Report

    Community guidelines

    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

    Re: The following script will resize the canvas to square bas... (12)

    Re: The following script will resize the canvas to square bas... (13) Re: The following script will resize the canvas to square bas... (14)

    Community Expert ,

    /t5/photoshop-ecosystem-discussions/batch-resizing-photos-of-different-dimensions/m-p/11075240#M325008 Apr 23, 2020 Apr 23, 2020

    Copy link to clipboard

    Copied

    Actions can not handle sizing of document well when they have various document Aspect Ratio and sizes. To size them to a common aspect ratio and size you need to use Photoshop scripting. A script cancrop the images to the outputimageAspect Ratio and resample or set the print resolution of the crop to the output image size soit will have the correct numberof pixels and the correct print resolution.

    I wrote two Photoshop Plug-In Script Aspect Ratio Slection "AspectRatioSelection.jsx" andLong Side Print Length "LongSidePrintLength.jsx" Youcan use in action to enable you to create actionthat will do what you want to do. Theyare in my craftingAction Package. The Resolution is changedfor the crop the imageis not resampled via the plug-in after the aspect ration selection crop is made.

    Crafting Actions PackageUPDATED Aug 10, 2014 Added Conditional Action steps to Action Palette Tips.
    Contains

    Example
    Download

    JJMack

    Votes

    Upvote

    Translate

    Translate

    Report

    Report

    • Follow
    • Report

    Community guidelines

    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

    Re: The following script will resize the canvas to square bas... (15)

    Re: The following script will resize the canvas to square bas... (16) Re: The following script will resize the canvas to square bas... (17)

    Community Expert ,

    /t5/photoshop-ecosystem-discussions/batch-resizing-photos-of-different-dimensions/m-p/11075987#M325101 Apr 24, 2020 Apr 24, 2020

    Copy link to clipboard

    Copied

    The following script will resize the canvas to square based on the longest edge, effectively "letterboxing" a landscape image or the opposite on a portrait image. The canvas extension colour is white. You can remove the // comment double slashes from the code to enable resizing, then change the dimensions from 1020,1020 to whatever pixel size you require.

    /* https://forums.adobe.com/message/6424562#6424562 */#target photoshop// Save the current ruler units and set to pixelsvar savedRuler = app.preferences.rulerUnits;app.preferences.rulerUnits = Units.PIXELS; var backgroundC = new SolidColor(); backgroundC.rgb.red = 255; backgroundC.rgb.green = 255; backgroundC.rgb.blue = 255; backgroundColor = backgroundC; var doc = app.activeDocument; doc.resizeCanvas(Math.max(doc.width,doc.height),Math.max(doc.width,doc.height))// Uncomment the line below to fit to a 1020px square rather than longest edge//doc.resizeImage(1020,1020) // Restore the ruler unitsapp.preferences.rulerUnits = savedRuler;

    Votes

    2 Upvotes

    Translate

    Translate

    Report

    Report

    • Follow
    • Report

    Community guidelines

    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

    Re: The following script will resize the canvas to square bas... (18)

    Re: The following script will resize the canvas to square bas... (19) Re: The following script will resize the canvas to square bas... (20)

    Community Expert ,

    /t5/photoshop-ecosystem-discussions/batch-resizing-photos-of-different-dimensions/m-p/11076169#M325118 Apr 24, 2020 Apr 24, 2020

    Copy link to clipboard

    Copied

    In Response To Stephen Marsh

    Resize the canvas to the smaller side will crop the image square. Also contentaware fill can fill the added white canvas above. I prefer crop.

    JJMack

    Votes

    Upvote

    Translate

    Translate

    Report

    Report

    • Follow
    • Report

    Community guidelines

    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

    Re: The following script will resize the canvas to square bas... (21)

    Re: The following script will resize the canvas to square bas... (22) Re: The following script will resize the canvas to square bas... (23)

    Community Expert ,

    /t5/photoshop-ecosystem-discussions/batch-resizing-photos-of-different-dimensions/m-p/11076184#M325120 Apr 24, 2020 Apr 24, 2020

    Copy link to clipboard

    Copied

    In Response To JJMack

    Agreed JJMack, for anybody wishing to try this, just change both instances of:

    Math.max

    to

    Math.min

    Votes

    Upvote

    Translate

    Translate

    Report

    Report

    • Follow
    • Report

    Community guidelines

    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

    Re: The following script will resize the canvas to square bas... (24)

    Re: The following script will resize the canvas to square bas... (25)

    New Here ,

    /t5/photoshop-ecosystem-discussions/batch-resizing-photos-of-different-dimensions/m-p/11076295#M325129 Apr 24, 2020 Apr 24, 2020

    Copy link to clipboard

    Copied

    In Response To Stephen Marsh

    Thank you for this! However I'm having trouble finding a way to put this script into Photoshop. I downloaded "Sublime Text" to allow me to save a js file but it says I don't have permission. How do I get this code into Photoshop as the correct file type on a MacBook Pro? I need to do this before I move this file into the Photoshop Scripts folder right?

    Thanks in advance!

    Votes

    Upvote

    Translate

    Translate

    Report

    Report

    • Follow
    • Report

    Community guidelines

    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

    Re: The following script will resize the canvas to square bas... (26)

    Re: The following script will resize the canvas to square bas... (27) Re: The following script will resize the canvas to square bas... (28)

    Community Expert ,

    /t5/photoshop-ecosystem-discussions/batch-resizing-photos-of-different-dimensions/m-p/11076356#M325137 Apr 24, 2020 Apr 24, 2020

    Copy link to clipboard

    Copied

    In Response To Kayleah72

    Any plain text editor will do. Be careful of Apple TextEdit. It has both plain text and rich text modes. BareBones Softwared BBEdit or Atom are also good choices for text editing on the Mac.

    More here on scripts:

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

    Re: The following script will resize the canvas to square bas... (29)

    Downloading JavaScript Files Many legacy ExtendScript-based scripts are offered in .js or .jsx or even .jsxbin formats. Simply downloa...

    Votes

    Upvote

    Translate

    Translate

    Report

    Report

    • Follow
    • Report

    Community guidelines

    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

    Re: The following script will resize the canvas to square bas... (30)

    Re: The following script will resize the canvas to square bas... (31)

    Community Beginner ,

    /t5/photoshop-ecosystem-discussions/batch-resizing-photos-of-different-dimensions/m-p/11323466#M351510 Jul 29, 2020 Jul 29, 2020

    Copy link to clipboard

    Copied

    LATEST

    In Response To Stephen Marsh

    This has absolutly saved my life. Thank you so much for this!

    Votes

    Upvote

    Translate

    Translate

    Report

    Report

    • Follow
    • Report

    Community guidelines

    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

    Re: The following script will resize the canvas to square bas... (32)

    Re: The following script will resize the canvas to square bas... (33)

    Re: The following script will resize the canvas to square bas... (34)

    Re: The following script will resize the canvas to square bas... (2025)

    References

    Top Articles
    Latest Posts
    Recommended Articles
    Article information

    Author: Prof. Nancy Dach

    Last Updated:

    Views: 6480

    Rating: 4.7 / 5 (57 voted)

    Reviews: 88% of readers found this page helpful

    Author information

    Name: Prof. Nancy Dach

    Birthday: 1993-08-23

    Address: 569 Waelchi Ports, South Blainebury, LA 11589

    Phone: +9958996486049

    Job: Sales Manager

    Hobby: Web surfing, Scuba diving, Mountaineering, Writing, Sailing, Dance, Blacksmithing

    Introduction: My name is Prof. Nancy Dach, I am a lively, joyous, courageous, lovely, tender, charming, open person who loves writing and wants to share my knowledge and understanding with you.