Link in Zwischenablage kopieren
Kopiert
I'm trying to save a Photoshop file, changing the width and height to 50%, the resolution to 300, and keeping transparency. If I save as .png, it flattens the layers.
Saving as "Save for Web" works, but for some reason, it is changing the resolution to 72 and the width to 37in. If I open the image in Photoshop and change the resolution to 300, I get the correct width of 8.88in.
Here is what I have in the script. I'm new to javascript so bear with me.
var xMaxFullDimension=activeDocument.width.as('in'); | ||
var yMaxFullDimension=activeDocument.height.as('in'); | ||
activeDocument.resizeImage(new UnitValue(xMaxFullDimension*50/100,'in'), new UnitValue(yMaxFullDimension*50/100,'in'), 300, ResampleMethod.BICUBIC); |
sfwPNG24(saveFile,100); | |
function sfwPNG24(saveFile,quality){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG;
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = false;
pngOpts.resolution=300;
pngOpts.quality = quality;
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);
}
You can use just a normal save as rather than save for web to keep the 300 dpi. You can use scriptlistener to record all the code.
Link in Zwischenablage kopieren
Kopiert
Since this is save for web, the default web dpi is 72, so it changes the file to that, adjusting the length in inches. The pixel res remains the same. I'm not sure there is anything you can do.
Link in Zwischenablage kopieren
Kopiert
You can use just a normal save as rather than save for web to keep the 300 dpi. You can use scriptlistener to record all the code.
Link in Zwischenablage kopieren
Kopiert
saveAs works like in Photoshop UI, ie. converts open document to new fileformat (which for PNG means flattening layers). But you can just duplicate the original doc and use saveAs on that and close it.
var tmp = original.duplicate("export_tmp")
tmp.saveAs(saveFile, pngOpts, false, Extension.NONE)
tmp.close(SaveOptions.DONOTSAVECHANGES)
Link in Zwischenablage kopieren
Kopiert
Chuck, I had tried just using the save function but it was flattening the file. I used the scriptListener and that solved my problem.
Matias, I tried your approach but it paused to ask for the file name. This is a batch process that is converting hundreds of covers.
Link in Zwischenablage kopieren
Kopiert
Add app.displayDialogs = DialogModes.NO
Link in Zwischenablage kopieren
Kopiert
Thanks.
Weitere Inspirationen, Events und Ressourcen finden Sie in der neuen Adobe Community
Jetzt ansehen