Packages

 

com.aspose.imaging.imageoptions

Class PsdOptions

  • All Implemented Interfaces:
    com.aspose.ms.System.IDisposable, Closeable, AutoCloseable


    public class PsdOptions
    extends ImageOptionsBase

    The psd file format create options.

    Code example:

    This example demonstrates the use of Aspose.Imaging for Java API to convert Images to PSD format. To achieve this goal this example loads an existing image and then saves it back to PSD format.


    
    // Create an instance of image class and initialize it with an existing file through File path
    com.aspose.imaging.Image image = com.aspose.imaging.Image.load("C:\\temp\\sample.bmp");
    try {
        // Create an instance of PsdOptions class
        com.aspose.imaging.imageoptions.PsdOptions psdOptions = new com.aspose.imaging.imageoptions.PsdOptions();
    
        // Set the CompressionMethod as RLE
        // Note: Other supported CompressionMethod is CompressionMethod.RAW [No Compression]
        psdOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.RLE);
    
        // Set the ColorMode to GrayScale
        // Note: Other supported ColorModes are ColorModes.Bitmap and ColorModes.RGB
        psdOptions.setColorMode(com.aspose.imaging.fileformats.psd.ColorModes.Grayscale);
    
        // Save the image to disk with the supplied PsdOptions settings
        image.save("C:\\temp\\output.psd", psdOptions);
    } finally {
        image.dispose();
    }
    

    • Constructor Detail

      • PsdOptions

        public PsdOptions()

        Initializes a new instance of the PsdOptions class.

      • PsdOptions

        public PsdOptions(PsdOptions options)

        Initializes a new instance of the PsdOptions class.

        Parameters:
        options - The options.
      • PsdOptions

        public PsdOptions(PsdImage image)

        Initializes a new instance of the PsdOptions class.

        Parameters:
        image - The image.
    • Method Detail

      • getResources

        public ResourceBlock[] getResources()

        Gets or sets the psd resources.

        Value: The psd resources.
      • setResources

        public void setResources(ResourceBlock[] value)

        Gets or sets the psd resources.

        Value: The psd resources.
        Code example:

        This example shows how to save a PNG image to PSD format using various PSD-specific options.


        String dir = "c:\\temp\\";
        
        // Create a PNG image of 100x100 px.
        com.aspose.imaging.fileformats.png.PngImage pngImage = new com.aspose.imaging.fileformats.png.PngImage(100, 100, com.aspose.imaging.fileformats.png.PngColorType.TruecolorWithAlpha);
        try {
            // Define a linear blue-transparent gradient.
            com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush(
                    new com.aspose.imaging.Point(0, 0),
                    new com.aspose.imaging.Point(pngImage.getWidth(), pngImage.getHeight()),
                    com.aspose.imaging.Color.getBlue(),
                    com.aspose.imaging.Color.getTransparent());
        
            com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(pngImage);
        
            // Fill the PNG image with the linear blue-transparent gradient.
            graphics.fillRectangle(gradientBrush, pngImage.getBounds());
        
            // The following options will be used to save the PNG image to PSD format.
            com.aspose.imaging.imageoptions.PsdOptions saveOptions = new com.aspose.imaging.imageoptions.PsdOptions();
        
            // The number of bits per channel
            saveOptions.setChannelBitsCount((byte) 8);
        
            // The number of channels. One channel for each color component R,G,B,A
            saveOptions.setChannelsCount((short) 4);
        
            // The color mode
            saveOptions.setColorMode(com.aspose.imaging.fileformats.psd.ColorModes.Rgb);
        
            // No compression
            saveOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.Raw);
        
            // Default version is 6
            saveOptions.setVersion(com.aspose.imaging.fileformats.psd.PsdImage.DEFAULT_VERSION);
        
            // Define a custom name for alpha channel
            com.aspose.imaging.fileformats.psd.resources.UnicodeAlphaNamesResource alphaNames = new com.aspose.imaging.fileformats.psd.resources.UnicodeAlphaNamesResource();
            alphaNames.setAlphaNames("The Alpha Channel");
        
            // Set the custom name for alpha channel
            saveOptions.setResources(new com.aspose.imaging.fileformats.psd.ResourceBlock[]{alphaNames});
        
            java.io.FileOutputStream stream = new java.io.FileOutputStream(dir + "saveoptions.psd");
            try {
                pngImage.save(stream, saveOptions);
                System.out.println("The size of the PSD image with RAW compression: " + stream.getChannel().size());
            } finally {
                stream.close();
            }
        
            stream = new java.io.FileOutputStream(dir + "saveoptions.RLE.psd");
            try {
                // The RLE compression allows to reduce the size of the output image
                saveOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.RLE);
        
                pngImage.save(stream, saveOptions);
                System.out.println("The size of the PSD image with RLE compression: " + stream.getChannel().size());
            } finally {
                stream.close();
            }
        
            // The output may look like this:
            // The size of the PSD image with RAW compression: 40090
            // The size of the PSD image with RLE compression: 16185
        } finally {
            pngImage.dispose();
        }
        

      • getVersion

        public int getVersion()

        Gets or sets the psd file version.

        Value: The psd file version.
      • setVersion

        public void setVersion(int value)

        Gets or sets the psd file version.

        Value: The psd file version.
        Code example:

        This example shows how to save a PNG image to PSD format using various PSD-specific options.


        String dir = "c:\\temp\\";
        
        // Create a PNG image of 100x100 px.
        com.aspose.imaging.fileformats.png.PngImage pngImage = new com.aspose.imaging.fileformats.png.PngImage(100, 100, com.aspose.imaging.fileformats.png.PngColorType.TruecolorWithAlpha);
        try {
            // Define a linear blue-transparent gradient.
            com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush(
                    new com.aspose.imaging.Point(0, 0),
                    new com.aspose.imaging.Point(pngImage.getWidth(), pngImage.getHeight()),
                    com.aspose.imaging.Color.getBlue(),
                    com.aspose.imaging.Color.getTransparent());
        
            com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(pngImage);
        
            // Fill the PNG image with the linear blue-transparent gradient.
            graphics.fillRectangle(gradientBrush, pngImage.getBounds());
        
            // The following options will be used to save the PNG image to PSD format.
            com.aspose.imaging.imageoptions.PsdOptions saveOptions = new com.aspose.imaging.imageoptions.PsdOptions();
        
            // The number of bits per channel
            saveOptions.setChannelBitsCount((byte) 8);
        
            // The number of channels. One channel for each color component R,G,B,A
            saveOptions.setChannelsCount((short) 4);
        
            // The color mode
            saveOptions.setColorMode(com.aspose.imaging.fileformats.psd.ColorModes.Rgb);
        
            // No compression
            saveOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.Raw);
        
            // Default version is 6
            saveOptions.setVersion(com.aspose.imaging.fileformats.psd.PsdImage.DEFAULT_VERSION);
        
            // Define a custom name for alpha channel
            com.aspose.imaging.fileformats.psd.resources.UnicodeAlphaNamesResource alphaNames = new com.aspose.imaging.fileformats.psd.resources.UnicodeAlphaNamesResource();
            alphaNames.setAlphaNames("The Alpha Channel");
        
            // Set the custom name for alpha channel
            saveOptions.setResources(new com.aspose.imaging.fileformats.psd.ResourceBlock[]{alphaNames});
        
            java.io.FileOutputStream stream = new java.io.FileOutputStream(dir + "saveoptions.psd");
            try {
                pngImage.save(stream, saveOptions);
                System.out.println("The size of the PSD image with RAW compression: " + stream.getChannel().size());
            } finally {
                stream.close();
            }
        
            stream = new java.io.FileOutputStream(dir + "saveoptions.RLE.psd");
            try {
                // The RLE compression allows to reduce the size of the output image
                saveOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.RLE);
        
                pngImage.save(stream, saveOptions);
                System.out.println("The size of the PSD image with RLE compression: " + stream.getChannel().size());
            } finally {
                stream.close();
            }
        
            // The output may look like this:
            // The size of the PSD image with RAW compression: 40090
            // The size of the PSD image with RLE compression: 16185
        } finally {
            pngImage.dispose();
        }
        

      • getCompressionMethod

        public short getCompressionMethod()

        Gets or sets the psd compression method.

        Value: The compression method.
      • setCompressionMethod

        public void setCompressionMethod(short value)

        Gets or sets the psd compression method.

        Value: The compression method.
        Code example:

        This example demonstrates the use of Aspose.Imaging for Java API to convert Images to PSD format. To achieve this goal this example loads an existing image and then saves it back to PSD format.


        
        // Create an instance of image class and initialize it with an existing file through File path
        com.aspose.imaging.Image image = com.aspose.imaging.Image.load("C:\\temp\\sample.bmp");
        try {
            // Create an instance of PsdOptions class
            com.aspose.imaging.imageoptions.PsdOptions psdOptions = new com.aspose.imaging.imageoptions.PsdOptions();
        
            // Set the CompressionMethod as RLE
            // Note: Other supported CompressionMethod is CompressionMethod.RAW [No Compression]
            psdOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.RLE);
        
            // Set the ColorMode to GrayScale
            // Note: Other supported ColorModes are ColorModes.Bitmap and ColorModes.RGB
            psdOptions.setColorMode(com.aspose.imaging.fileformats.psd.ColorModes.Grayscale);
        
            // Save the image to disk with the supplied PsdOptions settings
            image.save("C:\\temp\\output.psd", psdOptions);
        } finally {
            image.dispose();
        }
        

      • getPsdVersion

        public final byte getPsdVersion()

        Gets the file format version. It can be PSD or PSB.

        Value: The file format version.
        Returns:
        the file format version.
      • setPsdVersion

        public final void setPsdVersion(byte value)

        Sets the file format version. It can be PSD or PSB.

        Value: The file format version.
        Parameters:
        value - the file format version.
      • getColorMode

        public short getColorMode()

        Gets or sets the psd color mode.

        Value: The color mode.
      • setColorMode

        public void setColorMode(short value)

        Gets or sets the psd color mode.

        Value: The color mode.
        Code example:

        This example demonstrates the use of Aspose.Imaging for Java API to convert Images to PSD format. To achieve this goal this example loads an existing image and then saves it back to PSD format.


        
        // Create an instance of image class and initialize it with an existing file through File path
        com.aspose.imaging.Image image = com.aspose.imaging.Image.load("C:\\temp\\sample.bmp");
        try {
            // Create an instance of PsdOptions class
            com.aspose.imaging.imageoptions.PsdOptions psdOptions = new com.aspose.imaging.imageoptions.PsdOptions();
        
            // Set the CompressionMethod as RLE
            // Note: Other supported CompressionMethod is CompressionMethod.RAW [No Compression]
            psdOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.RLE);
        
            // Set the ColorMode to GrayScale
            // Note: Other supported ColorModes are ColorModes.Bitmap and ColorModes.RGB
            psdOptions.setColorMode(com.aspose.imaging.fileformats.psd.ColorModes.Grayscale);
        
            // Save the image to disk with the supplied PsdOptions settings
            image.save("C:\\temp\\output.psd", psdOptions);
        } finally {
            image.dispose();
        }
        

      • getChannelBitsCount

        public short getChannelBitsCount()

        Gets or sets the bits count per color channel.

        Value: The bits count per color channel.
      • setChannelBitsCount

        public void setChannelBitsCount(short value)

        Gets or sets the bits count per color channel.

        Value: The bits count per color channel.
        Code example:

        This example shows how to save a PNG image to PSD format using various PSD-specific options.


        String dir = "c:\\temp\\";
        
        // Create a PNG image of 100x100 px.
        com.aspose.imaging.fileformats.png.PngImage pngImage = new com.aspose.imaging.fileformats.png.PngImage(100, 100, com.aspose.imaging.fileformats.png.PngColorType.TruecolorWithAlpha);
        try {
            // Define a linear blue-transparent gradient.
            com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush(
                    new com.aspose.imaging.Point(0, 0),
                    new com.aspose.imaging.Point(pngImage.getWidth(), pngImage.getHeight()),
                    com.aspose.imaging.Color.getBlue(),
                    com.aspose.imaging.Color.getTransparent());
        
            com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(pngImage);
        
            // Fill the PNG image with the linear blue-transparent gradient.
            graphics.fillRectangle(gradientBrush, pngImage.getBounds());
        
            // The following options will be used to save the PNG image to PSD format.
            com.aspose.imaging.imageoptions.PsdOptions saveOptions = new com.aspose.imaging.imageoptions.PsdOptions();
        
            // The number of bits per channel
            saveOptions.setChannelBitsCount((byte) 8);
        
            // The number of channels. One channel for each color component R,G,B,A
            saveOptions.setChannelsCount((short) 4);
        
            // The color mode
            saveOptions.setColorMode(com.aspose.imaging.fileformats.psd.ColorModes.Rgb);
        
            // No compression
            saveOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.Raw);
        
            // Default version is 6
            saveOptions.setVersion(com.aspose.imaging.fileformats.psd.PsdImage.DEFAULT_VERSION);
        
            // Define a custom name for alpha channel
            com.aspose.imaging.fileformats.psd.resources.UnicodeAlphaNamesResource alphaNames = new com.aspose.imaging.fileformats.psd.resources.UnicodeAlphaNamesResource();
            alphaNames.setAlphaNames("The Alpha Channel");
        
            // Set the custom name for alpha channel
            saveOptions.setResources(new com.aspose.imaging.fileformats.psd.ResourceBlock[]{alphaNames});
        
            java.io.FileOutputStream stream = new java.io.FileOutputStream(dir + "saveoptions.psd");
            try {
                pngImage.save(stream, saveOptions);
                System.out.println("The size of the PSD image with RAW compression: " + stream.getChannel().size());
            } finally {
                stream.close();
            }
        
            stream = new java.io.FileOutputStream(dir + "saveoptions.RLE.psd");
            try {
                // The RLE compression allows to reduce the size of the output image
                saveOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.RLE);
        
                pngImage.save(stream, saveOptions);
                System.out.println("The size of the PSD image with RLE compression: " + stream.getChannel().size());
            } finally {
                stream.close();
            }
        
            // The output may look like this:
            // The size of the PSD image with RAW compression: 40090
            // The size of the PSD image with RLE compression: 16185
        } finally {
            pngImage.dispose();
        }
        

      • getChannelsCount

        public short getChannelsCount()

        Gets the color channels count.

        Returns:
        The color channels count.
      • setChannelsCount

        public void setChannelsCount(short value)

        Sets the color channels count.

        Parameters:
        value - The color channels count.
        Code example:

        This example shows how to save a PNG image to PSD format using various PSD-specific options.


        String dir = "c:\\temp\\";
        
        // Create a PNG image of 100x100 px.
        com.aspose.imaging.fileformats.png.PngImage pngImage = new com.aspose.imaging.fileformats.png.PngImage(100, 100, com.aspose.imaging.fileformats.png.PngColorType.TruecolorWithAlpha);
        try {
            // Define a linear blue-transparent gradient.
            com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush(
                    new com.aspose.imaging.Point(0, 0),
                    new com.aspose.imaging.Point(pngImage.getWidth(), pngImage.getHeight()),
                    com.aspose.imaging.Color.getBlue(),
                    com.aspose.imaging.Color.getTransparent());
        
            com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(pngImage);
        
            // Fill the PNG image with the linear blue-transparent gradient.
            graphics.fillRectangle(gradientBrush, pngImage.getBounds());
        
            // The following options will be used to save the PNG image to PSD format.
            com.aspose.imaging.imageoptions.PsdOptions saveOptions = new com.aspose.imaging.imageoptions.PsdOptions();
        
            // The number of bits per channel
            saveOptions.setChannelBitsCount((byte) 8);
        
            // The number of channels. One channel for each color component R,G,B,A
            saveOptions.setChannelsCount((short) 4);
        
            // The color mode
            saveOptions.setColorMode(com.aspose.imaging.fileformats.psd.ColorModes.Rgb);
        
            // No compression
            saveOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.Raw);
        
            // Default version is 6
            saveOptions.setVersion(com.aspose.imaging.fileformats.psd.PsdImage.DEFAULT_VERSION);
        
            // Define a custom name for alpha channel
            com.aspose.imaging.fileformats.psd.resources.UnicodeAlphaNamesResource alphaNames = new com.aspose.imaging.fileformats.psd.resources.UnicodeAlphaNamesResource();
            alphaNames.setAlphaNames("The Alpha Channel");
        
            // Set the custom name for alpha channel
            saveOptions.setResources(new com.aspose.imaging.fileformats.psd.ResourceBlock[]{alphaNames});
        
            java.io.FileOutputStream stream = new java.io.FileOutputStream(dir + "saveoptions.psd");
            try {
                pngImage.save(stream, saveOptions);
                System.out.println("The size of the PSD image with RAW compression: " + stream.getChannel().size());
            } finally {
                stream.close();
            }
        
            stream = new java.io.FileOutputStream(dir + "saveoptions.RLE.psd");
            try {
                // The RLE compression allows to reduce the size of the output image
                saveOptions.setCompressionMethod(com.aspose.imaging.fileformats.psd.CompressionMethod.RLE);
        
                pngImage.save(stream, saveOptions);
                System.out.println("The size of the PSD image with RLE compression: " + stream.getChannel().size());
            } finally {
                stream.close();
            }
        
            // The output may look like this:
            // The size of the PSD image with RAW compression: 40090
            // The size of the PSD image with RLE compression: 16185
        } finally {
            pngImage.dispose();
        }
        

      • isRemoveGlobalTextEngineResource

        public boolean isRemoveGlobalTextEngineResource()

        Gets a value indicating whether - Remove the global text engine resource - Used for some text-layered psd files, in only case, when they can not be opened in Adobe Photoshop after processing (mostly for absent fonts text layers related). After using this option, user need to Make next in opened in Photoshop file: Menu "Text" -> "Process absent fonts". After that operation all text will appear again. Please note, that this operation may cause some final layout changes.

        Returns:
        true if [remove global text engine resource]; otherwise, false.
      • setRemoveGlobalTextEngineResource

        public void setRemoveGlobalTextEngineResource(boolean value)

        Sets a value indicating whether - Remove the global text engine resource - Used for some text-layered psd files, in only case, when they can not be opened in Adobe Photoshop after processing (mostly for absent fonts text layers related). After using this option, user need to Make next in opened in Photoshop file: Menu "Text" -> "Process absent fonts". After that operation all text will appear again. Please note, that this operation may cause some final layout changes.

        Parameters:
        value - true if [remove global text engine resource]; otherwise, false.
      • isRefreshImagePreviewData

        public boolean isRefreshImagePreviewData()

        Gets a value indicating whether [refresh image preview data] - option used to maximize compatibility with another PSD image viewers.

        Returns:
        true if [refresh image preview data]; otherwise, false.
      • setRefreshImagePreviewData

        public void setRefreshImagePreviewData(boolean value)

        Sets a value indicating whether [refresh image preview data] - option used to maximize compatibility with another PSD image viewers.

        Parameters:
        value - true if [refresh image preview data]; otherwise, false.