Copy link to clipboard
Copied
I'm working on a Mac in Photoshop 2024 and am using the below script to pull an .ai file from a set of folders and export it out as a png that is 1154px wide but keeps its apsect ratio vertically. Then it should export that .png file back out in the same folder that it exported the .ai file from. The below works fine on PC, but on MAC it skews the aspect ratio for some of the exported .png files and it also changes some of the colour logos to grayscale. Does anyone have any suggestions as to why it would do that?
// Function to process AI files in a folder and its subfolders
function processAIFiles(folder) {
var files = folder.getFiles();
for (var i = 0; i < files.length; i++) {
if (files[i] instanceof Folder) {
// Recursive call for subfolders
processAIFiles(files[i]);
} else if (files[i] instanceof File && files[i].name.match(/\.ai$/i)) {
var doc = app.open(files[i]);
if (doc) {
// Change width to 1154px
var newWidth = 1154;
var newHeight = (newWidth / doc.width) * doc.height;
// Set resolution to 300 dpi
doc.resizeImage(newWidth, newHeight, 300, ResampleMethod.BICUBICSHARPER);
// Save as PNG
var pngOptions = new PNGSaveOptions();
pngOptions.quality = 12; // High quality
var pngFile = new File(files[i].parent + "/" + doc.name.replace(".ai", ".png"));
doc.saveAs(pngFile, pngOptions);
// Close the document without saving changes to AI file
doc.close(SaveOptions.DONOTSAVECHANGES);
}
}
}
}
Try the following steps on Mac OS
1) Manually open any of the .ai files in Photoshop and set the color mode, aspect ratio settings.
2) Close the file
3) Run the script
I think Photoshop opens your files with the latest Import PDF window settings when the script runs.
At least it worked for me. At first your script exported distorted proportions. But after the steps you took, the script miraculously worked.
Copy link to clipboard
Copied
Try the following steps on Mac OS
1) Manually open any of the .ai files in Photoshop and set the color mode, aspect ratio settings.
2) Close the file
3) Run the script
I think Photoshop opens your files with the latest Import PDF window settings when the script runs.
At least it worked for me. At first your script exported distorted proportions. But after the steps you took, the script miraculously worked.
Copy link to clipboard
Copied
OMG Thank you! This sorted it! Will remember this going forward!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now