Skip to main content
nickg2021
Participating Frequently
December 1, 2009
Question

How do I script a PNG24 file to have white opaque background

  • December 1, 2009
  • 1 reply
  • 1595 views

I have a script that will export layers to png files but I want each layer to have a white background and not a transparent background

I am using these sets of export options.

var exportOptions = new ExportOptionsPNG24();

exportOptions.antiAliasing = true;

exportOptions.matte = true;

exportOptions.matteColor = RGBColorobject;

exportOptions.transparency = false;

I know I am using the exportOptions.matteColor = RGBColorobject; incorrectly but need some direction on how to get this to work.

even when I delete that line and have the transparency set to false and the matte = true I still get a transparent background.
Any coaching will be appreciated.

This topic has been closed for replies.

1 reply

Larry G. Schneider
Community Expert
Community Expert
December 1, 2009

Delete the matte color line and try setting artBoardClipping to true.

nickg2021
nickg2021Author
Participating Frequently
December 1, 2009

Thanks for responding Larry,

I did that and when I open the png file in photoshop it still has a transparent background.

usually transparent backgrounds would be great but I need to isolate some patterns to be used on a 3D model in PS CS4

All the references I see say to just mark transparency as false…

Nick

Muppet_Mark-QAl63s
Inspiring
December 2, 2009

Thanks!

I tried it and it still does not generate a white background.

I am going to post the illustrator file and the photoshop png result in another post.

I have to be doing something incredibly stupid wrong with the color space and am too bleary-eyed to see it


Give this a try? I think what is need to to set 'transparency = false' before matte = true; this works in CS2

#target illustrator

var userHome = Folder("~").fsName.toString();

var fileRef = new File (userHome + '/Desktop/Marks_Star.png');

docRef = activeDocument;

exportAsPNG24File(fileRef, 'Flat');

function exportAsPNG24File(saveFile, x) {

var exportType = ExportType.PNG24;

var png24Options = new ExportOptionsPNG24();

with (png24Options) {

switch(x) {

case 'Flat' :

transparency = false;

var bgMatte = new RGBColor();

bgMatte.red = 255; bgMatte.green = 255; bgMatte.blue = 255;

matte = true;

matteColor = bgMatte; break;

case 'Tran' :

matte = false;

transparency = true; break;

}

antiAliasing = true;

artBoardClipping = true;

horizontalScale = 100;

saveAsHTML = false;

verticalScale = 100;

}

docRef.exportFile(saveFile, exportType, png24Options);

}