Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Save as PNG with transparency

Entdecker ,
Jul 17, 2016 Jul 17, 2016

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);

}

THEMEN
Aktionen und Skripte
1.1K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines

correct answers 1 richtige Antwort

Community Expert , Jul 17, 2016 Jul 17, 2016

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.

Übersetzen
Adobe
Community Expert ,
Jul 17, 2016 Jul 17, 2016

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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Jul 17, 2016 Jul 17, 2016

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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Enthusiast ,
Jul 17, 2016 Jul 17, 2016

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)

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Jul 18, 2016 Jul 18, 2016

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.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Enthusiast ,
Jul 18, 2016 Jul 18, 2016

Add ​app.displayDialogs = DialogModes.NO

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Jul 19, 2016 Jul 19, 2016
AKTUELL

Thanks.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines