Canvas 在PhotoShop中调整批处理图像的大小

Canvas 在PhotoShop中调整批处理图像的大小,canvas,automation,photoshop,image-resizing,Canvas,Automation,Photoshop,Image Resizing,我经常被要求将图像(很多)调整为正方形,然后用PhotoShop保存。例如,如果图像是400x200,则需要将画布的大小调整为400x400。同样,如果图像为321x850,则画布的大小将调整为850x850,如果图像为521x250,则画布的大小将调整为521x521 PhotoShop中有没有一种方法可以自动完成这项繁琐的任务?我知道PhotoShop Automatic,它记录你的动作,但那不是我想要的。如果你能给我指出正确的方向,我对编程解决方案没有问题。这可能吗 先谢谢你。这可以为我节

我经常被要求将图像(很多)调整为正方形,然后用PhotoShop保存。例如,如果图像是400x200,则需要将画布的大小调整为400x400。同样,如果图像为321x850,则画布的大小将调整为850x850,如果图像为521x250,则画布的大小将调整为521x521

PhotoShop中有没有一种方法可以自动完成这项繁琐的任务?我知道PhotoShop Automatic,它记录你的动作,但那不是我想要的。如果你能给我指出正确的方向,我对编程解决方案没有问题。这可能吗


先谢谢你。这可以为我节省数小时繁琐的重复工作。

使用javascript:您可以使用它来选择所选文件夹中的所有文件并循环浏览它们。在循环中,您将希望按如下方式打开每个文件:

var doc = open(fileList[i]);
然后检查长度与宽度:

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.
    }
}
保存并关闭:

doc.save();
doc.close();
根据您要查找的内容,还有
doc.resizeImage()


在Mac OS X中批量调整图像大小

通过使用附带的预览应用程序,您可以在Mac OS X中轻松批量调整图像组大小,无需任何额外下载或昂贵的照片编辑应用程序,只需预览,这在您的Mac上是免费的!以下是如何做到这一点:

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!

这在几乎所有版本的Mac OS X中都包含的预览中起作用,快乐批量调整大小

使用此脚本时出错

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.
     } }

它说第4行非法使用了else,因为第3行末尾缺少“}”,所以出现了错误。 在打开else术语之前,必须先关闭if术语

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.
 }

我认为你应该使用VSO图像大小调整器,有时我必须做类似的事情,你必须将模式设置为中心,仅此而已。使用JS编写脚本对我来说应该没问题,谢谢你错误地关闭了括号…你应该在else语句之前有一个小括号。我也会把你的最后一个推下一行,保持你的缩进/嵌套-帮助你发现循环不太正确的地方