So the below script simply loops through a chosen folder, checks canvas size and dimensions and sets them if they're not in a 1:1 aspect ratio, and if they are, leaves them alone. The result is all images in the folder saved in 1:1 aspect ratio at dimension of 1000 x 1000 px.
The problem is they're all saved as .JPG whereas I would prefer to save them as transparent PNG-24.
I assume somewhere in the doc.save()
method there is a parameter for different file types? I cannot find any documentation on this and was wondering if someone more knowledgeable knew? Thank you!
var inputFolder = Folder.selectDialog("Select a folder to process"),
fileList = inputFolder.getFiles(/\.(jpg|tif|psd|crw|cr2|nef|dcr|dc2|raw)$/i);
for(var i=0; i < fileList.length; i++) {
var doc = open(fileList[i]);
if(doc.width !== doc.height) {
if(doc.width > doc.height) {
doc.resizeCanvas(doc.width, doc.width)
} else {
doc.resizeCanvas(doc.height, doc.height)
}
}
if((doc.width && doc.height) > 1000) {
doc.resizeImage(1000, 1000);
} else {
doc.resizeImage(doc.width, doc.height);
}
doc.save();
doc.close();
}