I've tried setting it to MatteType.BLACK, MatteType.BACKGROUND, etc. but the background of the saved image is always white. Setting a matte color works with the normal Photoshop SaveAs dialog when saving as a JPEG but apparently not in scripts:
jpegOptions = new JPEGSaveOptions(); jpegOptions.embedColorProfile = true; jpegOptions.formatOptions = FormatOptions.STANDARDBASELINE; jpegOptions.matte = MatteType.BLACK; jpegOptions.quality = 8; doc.saveAs(jpegFile, jpegOptions, true, Extension.LOWERCASE);
Is there something else I need to do?
People have recommended using ExportOptionsSaveForWeb/exportDocument instead but it would be nice to be able to use the canonical method if it works.
jpegOptions.matte = MatteType.BLACK;
will only works if the active document has transparent area(s) (and not only a "nontransparent" background layer).
Save a file with layers and transparent areas as *.psd and after than try your code again.
Thanks pixxxel for the quick reply!
I realized that the document is getting flattened (elsewhere in the script) before it is saved so, you're right, it lost all its layers and transparency of course. A stupid mistake on my part...