Resize and export out .ai to png using a script in Photoshop (MAC Issue)
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);
}
}
}
}

