У меня есть скрипт, который проверяет, имеет ли изображение ширину более 250 пикселей и если оно выше 300 пикселей, и если какое-либо из этих утверждений истинно, оно должно изменить их размер до вписываются в оба эти значения. Затем он должен сохранять их как jpg с расширением, большим для имени файла в папке с именем large. Однако я не знаю, как сделать фотошоп открытым все файлы в данной папке и выполнить сценарий, а также я не знаю, как правильно их экспортировать, прекращается фотошоп, когда он пытается экспортировать.Откройте все pdf-файлы в папке и сохраните как измененные jpg-файлы в другой папке
Вот мой код:
// get a reference to the current (active) document and store it in a variable named "doc"
doc = app.activeDocument;
// change the color mode to RGB. Important for resizing GIFs with indexed colors, to get better results
doc.changeMode(ChangeMode.RGB);
// these are our values for the END RESULT width and height (in pixels) of our image
var fWidth = 250;
var fHeight = 300;
// do the resizing. if height > width (portrait-mode) resize based on height. otherwise, resize based on width
if (doc.height > 300) { doc.resizeImage(null,UnitValue(fHeight,"300"),null,ResampleMethod.BICUBIC); }
else if (doc.width > 250) { doc.resizeImage(null,UnitValue(fWidth,"250"),null,ResampleMethod.BICUBIC); }
// Makes the default background white
var white = new SolidColor();
white.rgb.hexValue = "FFFFFF";
app.backgroundColor = white;
// Convert the canvas size as informed above for the END RESULT app.activeDocument.resizeCanvas(UnitValue(fWidth,"px"),UnitValue(fHeight,"px"));
// our web export options
var options = new ExportOptionsSaveForWeb();
options.quality = 70;
options.format = SaveDocumentType.JPEG;
options.optimized = true;
var newName = 'web-'+doc.name+'.jpg';
doc.exportDocument(File(doc.path+'/images/'+newName);