javascriptphotoshopphotoshop-script

How do I declare Tiff Save Options with Layer Compression value in photoshop?


I am trying to save my images in TIFF, I got the script but it doesn't work. Please help me to fix it

var tiffSaveOptions = new TiffSaveOptions();
    tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
    tiffSaveOptions.alphaChannels = true;
    tiffSaveOptions.saveImagePyramid = false;
    tiffSaveOptions.transparency = false;
    tiffSaveOptions.interleaveChannels = true;
    tiffSaveOptions.byteOrder = ByteOrder.IBMPC;
    tiffSaveOptions.layerCompression = TIFFEncoding.TIFFZIP; //Also RLE Option
    doc.saveAs((new File(filepath + "/" + filename + ".tiff")),tiffSaveOptions,true);

Solution

  • This one is an easy fix (but took a while to get there ;)

    If you do want the old fashioned PC byte order it's:

    tiffSaveOptions.byteOrder = ByteOrder.IBM;
    

    although it seems to be outdated (see my link in the comments).

    In order to save with layer compression you need to declare

    tiffSaveOptions.layers = true;
    

    and then set

    tiffSaveOptions.layerCompression = LayerCompression.ZIP; //Also RLE Option
    

    Altogether it becomes:

    var tiffSaveOptions = new TiffSaveOptions();
    tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
    tiffSaveOptions.alphaChannels = true;
    tiffSaveOptions.saveImagePyramid = false;
    tiffSaveOptions.transparency = false;
    tiffSaveOptions.interleaveChannels = true;
    tiffSaveOptions.byteOrder = ByteOrder.IBM;
    tiffSaveOptions.layers = true;
    tiffSaveOptions.layerCompression = LayerCompression.ZIP; //Also RLE Option
    activeDocument.saveAs((new File(filepath + "/" + filename + ".tiff")),tiffSaveOptions,true);