#saveAs options cannot be set on instantiation for some (if not all) image formats [Photoshop, JavaScript API/Scripting]

  • 1
  • Problem
  • Updated 4 months ago
  • (Edited)
We've been finding that saveAs options aren't setting for many of the image formats when declared on instantiation. Instead, they need to be declared after the options have been instantiated (as illustrated in the code sample below). Since setting on instantiation fails silently, it took us a long time to realize our some of the settings weren't sticking.

function createSaveOptions(imageFormat) {
    switch(imageFormat) {
        //  this is how I would expect options could be set (instantiation)
        case "PSD":
            return new PhotoshopSaveOptions({
                alphaChannels: true,
                embedColorProfile: true,
                layers: true,
                spotColors: true
        // but this is the method that's working properly (after instantiation)
        case "TIF":
            var options = new TiffSaveOptions();
            options.transparency = true;
            options.embedColorProfile = true;
            return options
        case "JPG":
            var options = new JPEGSaveOptions();
            options.embedColorProfile = true;
            options.quality = 12;
            return options

Photo of Zollie Barnes

Zollie Barnes

  • 1 Post
  • 0 Reply Likes

Posted 4 months ago

  • 1

Be the first to post a reply!