Resize batch images in PhotoShop

邮差的信 提交于 2019-12-01 21:11:14
pdizz

Using javascript: You can use this answer to pick all the files in a chosen folder and loop through them. Within the loop you'll want to open each file like so:

var doc = open(fileList[i]);

then do a check of the length vs width:

if (doc.width !== doc.height) {             // if document is not already square...
    if (doc.width > doc.height) {               // if width is greater...
        doc.resizeCanvas(doc.width, doc.width)   // use this value for both sides...
    } else {                                      // else use height for both sides...
        doc.resizeCanvas(doc.height, doc.height)      // so you always get a square.
    }
}

save and close:

doc.save();
doc.close();

Depending on what you're looking for there is doc.resizeImage() as well.

Adobe scripting guides

Batch resize images in Mac OS X

You can easily batch resize groups of images within Mac OS X by using the included Preview app, there is no need for any additional downloads or expensive photo editing applications, only Preview, which is free with your Mac! Here’s how to do it:

1. Select all the images you want resized and open them within Preview
2. From Preview, select the images that you want to batch resize from the drawer (Command+A will select them all)
3. Now, go to the menu labeled Tools, and then Adjust Size
4. Enter a value for what you want the new width and height to be
5. Next, navigate to the File menu and click Save All
6. All the images you selected are now resized!

This works in Preview that is included in virtually all versions of Mac OS X, happy batch resizing!

Used this script it errors out.

if (doc.width !== doc.height) {             // if document is notalready square...
     if (doc.width > doc.height) {               // if width is greater...
         doc.resizeCanvas(doc.width, doc.width)   // use this value for both sides...
     else {                                      // else use height for both sides...
         doc.resizeCanvas(doc.height, doc.height)      // so you always get a square.
     } }

It says illegal use of else on line 4

The error occurs because there is a missing '}' at the end of line 3. The if-term has to be close BEFORE the else-term is opened.

if (doc.width !== doc.height) {                // if document is notalready square...
 if (doc.width > doc.height) {                 // if width is greater...
     doc.resizeCanvas(doc.width, doc.width)}   // use this value for both sides...
 else {                                        // else use height for both sides...
     doc.resizeCanvas(doc.height, doc.height)} // so you always get a square.
 }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!