public final class PsdImage extends RasterCachedMultipageImage implements com.aspose.imaging_internal.ILayerableImage
A PSD image.
This example shows how to load a PSD image from a file and transforms it to a grayscale image.
String dir = "c:\\temp\\"; // Load a PSD image. com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage(dir + "simple.psd"); try { // Do some image processing psdImage.grayscale(); psdImage.save(dir + "simple.grayscale.psd"); } finally { psdImage.dispose(); }
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_VERSION
The default PSD version.
|
Constructor and Description |
---|
PsdImage(InputStream stream)
Creates new instance of psd image
PsdImage class from specified path from raster image (not psd image in stream). |
PsdImage(InputStream stream,
short colorMode,
short channelBitDepth,
short channels,
int psdVersion,
short compression)
Creates new instance of psd image
PsdImage class from specified path from raster image (not psd image in stream) with constructor parameters. |
PsdImage(int width,
int height)
Creates new instance of psd image
PsdImage class with specified width and height. |
PsdImage(int width,
int height,
IColorPalette colorPalette,
short colorMode,
short channelBitDepth,
short channels,
int psdVersion,
short compression)
Creates new instance of psd image
PsdImage class with specified width,height, paletter, color mode, channels count and channels bit-length and specified compression mode parameters. |
PsdImage(RasterImage rasterImage)
Creates new instance of psd image
PsdImage class from existing raster image (not psd image) with RGB color mode with 4 channels 8 bit/channel and no compression. |
PsdImage(RasterImage rasterImage,
short colorMode,
short channelBitDepth,
short channels,
int psdVersion,
short compression)
Creates new instance of psd image
PsdImage class from existing raster image (not psd image) with constructor parameters. |
PsdImage(String path)
Creates new instance of psd image
PsdImage class from specified path from raster image (not psd image in path). |
PsdImage(String path,
short colorMode,
short channelBitDepth,
short channels,
int psdVersion,
short compression)
Creates new instance of psd image
PsdImage class from specified path from raster image (not psd image in path) with constructor parameters. |
Modifier and Type | Method and Description |
---|---|
BrightnessContrastLayer |
addBrightnessContrastAdjustmentLayer(int brightness,
int contrast)
Adds the brightness/contrast adjustment layer.
|
ChannelMixerLayer |
addChannelMixerAdjustmentLayer()
Adds the channel mixer adjustment layer with default parameters
|
CurvesLayer |
addCurvesAdjustmentLayer()
Adds the Curves Adjustment layer.
|
ExposureLayer |
addExposureAdjustmentLayer() |
ExposureLayer |
addExposureAdjustmentLayer(float exposure) |
ExposureLayer |
addExposureAdjustmentLayer(float exposure,
float offset) |
ExposureLayer |
addExposureAdjustmentLayer(float exposure,
float offset,
float gammaCorrection)
Adds the exposure adjustment layer.
|
ExposureLayer |
addExposureLayer() |
ExposureLayer |
addExposureLayer(float exposure) |
ExposureLayer |
addExposureLayer(float exposure,
float offset) |
ExposureLayer |
addExposureLayer(float exposure,
float offset,
float gammaCorrection)
Adds the exposure adjustment layer.
|
HueSaturationLayer |
addHueSaturationAdjustmentLayer()
Adds the hue/saturation adjustment layer.
|
void |
addLayer(Layer layer)
Adds the layer.
|
LayerGroup |
addLayerGroup(String groupName,
int index,
boolean startBehaviour)
Adds the layer group.
|
LevelsLayer |
addLevelsAdjustmentLayer()
Adds the Levels adjustment layer.
|
PhotoFilterLayer |
addPhotoFilterLayer(Color color)
Adds the photofilter layer.
|
Layer |
addRegularLayer()
Adds a new regular layer.
|
TextLayer |
addTextLayer(String text,
Rectangle rect)
Adds a new Text layer.
|
void |
crop(int leftShift,
int rightShift,
int topShift,
int bottomShift)
Crop image with shifts.
|
void |
crop(Rectangle rectangle)
Cropping the image.
|
void |
filter(Rectangle rectangle,
FilterOptionsBase options)
Filters the specified rectangle.
|
void |
flattenImage()
Flattens all layers.
|
Layer |
getActiveLayer()
Gets the active layer.
|
int |
getBitsPerChannel()
Gets the bits per channel.
|
int |
getBitsPerPixel()
Gets the image bits per pixel count.
|
int |
getChannelsCount()
Gets the PSD channels count.
|
StreamSource |
getCmykColorProfile()
The CMYK color profile for CMYK PSD images.
|
short |
getColorMode()
Gets the color mode.
|
short |
getCompression()
Gets the compression method.
|
Image |
getDefaultPage()
Gets the default page.
|
long |
getFileFormat()
Gets a value of file format
|
GlobalLayerMaskInfo |
getGlobalLayerMaskInfo()
Gets the global layer mask info.
|
LayerResource[] |
getGlobalLayerResources()
Gets the global layer resources.
|
StreamSource |
getGrayColorProfile()
The GRAY (monochrome) color profile for Grayscale PSD images.
|
int |
getHeight()
Gets the image height.
|
double |
getHorizontalResolution()
Gets the horizontal resolution, in pixels per inch, of this
PsdImage . |
float |
getImageOpacity()
Gets opacity of this image.
|
ResourceBlock[] |
getImageResources()
Gets the PSD image resources.
|
Layer[] |
getLayers()
Gets the PSD layers.
|
int |
getPageCount()
Gets the page count.
|
Image[] |
getPages()
Gets the pages.
|
PixelDataFormat |
getRawDataFormat()
Gets the raw data format.
|
StreamSource |
getRgbColorProfile()
The RGB color profile for CMYK PSD images.
|
int |
getVersion()
Gets the version.
|
double |
getVerticalResolution()
Gets the vertical resolution, in pixels per inch, of this
PsdImage . |
int |
getWidth()
Gets the image width.
|
XmpPacketWrapper |
getXmpData()
Gets the XMP metadata.
|
boolean |
hasAlpha()
Gets the vertical resolution, in pixels per inch, of this
RasterImage . |
boolean |
hasTransparencyData()
Gets or sets a value indicating whether first alpha channel contains the transparency data for the merged result when specifying layers data.
|
boolean |
hasTransparentColor()
Gets a value indicating whether image has transparent color.
|
boolean |
isFlatten()
Gets a value indicating whether psd image is flattened.
|
Layer |
mergeLayers(Layer bottomLayer,
Layer topLayer)
Merges the layers.
|
void |
resize(int newWidth,
int newHeight,
int resizeType)
Resizes the image.
|
void |
resizeHeightProportionally(int newHeight,
int resizeType)
Resizes the width proportionally.
|
void |
resizeWidthProportionally(int newWidth,
int resizeType)
Resizes the width proportionally.
|
void |
rotate(float angle,
boolean resizeProportionally,
Color backgroundColor)
!:RasterCahcedMultipageImage.Rotate image around the center. |
void |
rotateFlip(int rotateFlipType)
Rotates, flips, or rotates and flips the Active frame only.
|
void |
setActiveLayer(Layer value)
Sets the active layer.
|
void |
setCmykColorProfile(StreamSource value)
The CMYK color profile for CMYK PSD images.
|
void |
setColorMode(short value)
Sets the color mode.
|
void |
setGlobalLayerResources(LayerResource[] value)
Sets the global layer resources.
|
void |
setGrayColorProfile(StreamSource value)
The GRAY (monochrome) color profile for Grayscale PSD images.
|
void |
setHorizontalResolution(double value)
Sets the horizontal resolution, in pixels per inch, of this
PsdImage . |
void |
setImageResources(ResourceBlock[] value)
Sets the PSD image resources.
|
void |
setLayers(Layer[] value)
Sets the PSD layers.
|
void |
setRgbColorProfile(StreamSource value)
The RGB color profile for CMYK PSD images.
|
void |
setTransparencyData(boolean value)
Sets a value indicating whether first alpha channel contains the transparency data for the merged result when specifying layers data.
|
void |
setVersion(int value)
Sets the version.
|
void |
setVerticalResolution(double value)
Sets the vertical resolution, in pixels per inch, of this
PsdImage . |
void |
setXmpData(XmpPacketWrapper value)
Sets the XMP metadata.
|
adjustBrightness, adjustContrast, adjustGamma, adjustGamma, binarizeBradley, binarizeBradley, binarizeFixed, binarizeOtsu, cacheData, dither, getBackgroundColor, getPageExportingAction, grayscale, isCached, normalizeAngle, replaceColor, replaceNonTransparentColors, resize, rotateFlipAll, setBackgroundColor, setPageExportingAction
dither, getArgb32Pixel, getDefaultArgb32Pixels, getDefaultPixels, getDefaultRawData, getDefaultRawData, getModifyDate, getPixel, getPremultiplyComponents, getRawCustomColorConverter, getRawDataSettings, getRawFallbackIndex, getRawIndexedColorConverter, getRawLineSize, getSkewAngle, getTransparentColor, getUpdateXmpData, getUseRawData, isRawDataAvailable, loadArgb32Pixels, loadArgb64Pixels, loadCmyk32Pixels, loadCmykPixels, loadPartialArgb32Pixels, loadPartialPixels, loadPixels, loadRawData, loadRawData, normalizeAngle, readArgb32ScanLine, readScanLine, replaceColor, replaceNonTransparentColors, rotate, saveArgb32Pixels, saveCmyk32Pixels, saveCmykPixels, savePixels, saveRawData, setArgb32Pixel, setPalette, setPixel, setPremultiplyComponents, setRawCustomColorConverter, setRawFallbackIndex, setRawIndexedColorConverter, setResolution, setTransparentColor, setTransparentColor, setUpdateXmpData, setUseRawData, toBitmap, writeArgb32ScanLine, writeScanLine
canLoad, canLoad, canLoad, canLoad, canSave, create, getBounds, getBufferSizeHint, getContainer, getDefaultOptions, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getOriginalOptions, getPalette, getProgressEventHandler, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSize, hasBackgroundColor, isAutoAdjustPalette, load, load, load, load, load, load, resize, resizeHeightProportionally, resizeHeightProportionally, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalette
getDataStreamContainer, save, save, save, save
close, dispose, getDisposed
public static final int DEFAULT_VERSION
The default PSD version.
public PsdImage(String path)
Creates new instance of psd image PsdImage
class from specified path from raster image (not psd image in path). Used to initialize psd image with default parameters - Color mode - rgb, 4 channels, 8 bit per channel, Compression - Raw.
path
- The path to load pixel and palette data from and initialize with.This example shows how to load a PSD image from a file and transforms it to a grayscale image.
String dir = "c:\\temp\\"; // Load a PSD image. com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage(dir + "simple.psd"); try { // Do some image processing psdImage.grayscale(); psdImage.save(dir + "simple.grayscale.psd"); } finally { psdImage.dispose(); }
public PsdImage(String path, short colorMode, short channelBitDepth, short channels, int psdVersion, short compression)
Creates new instance of psd image PsdImage
class from specified path from raster image (not psd image in path) with constructor parameters.
path
- The path to load pixel and palette data from and initialize with.colorMode
- The color mode.channelBitDepth
- The PSD bit depth per channel.channels
- The PSD channels count.psdVersion
- The PSD version.compression
- The compression to use.This example shows how to load a PSD image from a file and transforms it to a grayscale 8-bit image.
String dir = "c:\\temp\\"; // Note that if the source image is colorful, it will be transformed to a 8-bit grayscale image as specified in the arguments. com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage( dir + "simple.psd", com.aspose.imaging.fileformats.psd.ColorModes.Grayscale, // The desired color mode (short) 8, // The number of bits per channel (short) 1, // The number of channels com.aspose.imaging.fileformats.psd.PsdImage.DEFAULT_VERSION, // The default version is 6 com.aspose.imaging.fileformats.psd.CompressionMethod.RLE); // The RLE compression allows to reduce the size of the output image try { psdImage.save(dir + "simple.grayscale.psd"); } finally { psdImage.dispose(); }
public PsdImage(InputStream stream)
Creates new instance of psd image PsdImage
class from specified path from raster image (not psd image in stream). Used to initialize psd image with default parameters - Color mode - rgb, 4 channels, 8 bit per channel, Compression - Raw.
stream
- The stream to load pixel and palette data from and initialize with.This example shows how to load a PSD image from a file stream and transforms it to a grayscale image.
String dir = "c:\\temp\\"; java.io.InputStream stream = new java.io.FileInputStream(dir + "simple.psd"); com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage(stream); try { // Do some image processing psdImage.grayscale(); psdImage.save(dir + "simple.grayscale.psd"); } finally { psdImage.dispose(); stream.close(); }
public PsdImage(InputStream stream, short colorMode, short channelBitDepth, short channels, int psdVersion, short compression)
Creates new instance of psd image PsdImage
class from specified path from raster image (not psd image in stream) with constructor parameters.
stream
- The stream to load pixel and palette data from and initialize with.colorMode
- The color mode.channelBitDepth
- The PSD bit depth per channel.channels
- The PSD channels count.psdVersion
- The PSD version.compression
- The compression to use.public PsdImage(RasterImage rasterImage)
Creates new instance of psd image PsdImage
class from existing raster image (not psd image) with RGB color mode with 4 channels 8 bit/channel and no compression.
rasterImage
- The image to load pixel and palette data from and initialize with.This example shows how to load a PSD image from another raster image and transforms it to a grayscale image.
String dir = "c:\\temp\\"; // A PSD image is built on a PNG image. com.aspose.imaging.fileformats.png.PngImage pngImage = new com.aspose.imaging.fileformats.png.PngImage(dir + "sample.png"); com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage(pngImage); try { // Do some image processing. psdImage.grayscale(); psdImage.save(dir + "sample.grayscale.psd"); } finally { psdImage.dispose(); pngImage.dispose(); }
public PsdImage(RasterImage rasterImage, short colorMode, short channelBitDepth, short channels, int psdVersion, short compression)
Creates new instance of psd image PsdImage
class from existing raster image (not psd image) with constructor parameters.
rasterImage
- The image to load pixel and palette data from and initialize with.colorMode
- The color mode.channelBitDepth
- The PSD bit depth per channel.channels
- The PSD channels count.psdVersion
- The PSD version.compression
- The compression to use.This example shows how to load a PSD image from another raster image with specified options and transforms it to a grayscale 8-bit image.
String dir = "c:\\temp\\"; com.aspose.imaging.fileformats.png.PngImage pngImage = new com.aspose.imaging.fileformats.png.PngImage(dir + "sample.png"); try { // Note that if the source image is colorful, it will be transformed to a 8-bit grayscale image as specified in the arguments. com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage( pngImage, com.aspose.imaging.fileformats.psd.ColorModes.Grayscale, // The desired color mode (short) 8, // The number of bits per channel (short) 1, // The number of channels com.aspose.imaging.fileformats.psd.PsdImage.DEFAULT_VERSION, // The default version is 6 com.aspose.imaging.fileformats.psd.CompressionMethod.RLE); // The RLE compression allows to reduce the size of the output image try { psdImage.save(dir + "sample.grayscale.psd"); } finally { psdImage.dispose(); } } finally { pngImage.dispose(); }
public PsdImage(int width, int height)
Creates new instance of psd image PsdImage
class with specified width and height. Used to initialize empty psd image.
width
- The image width.height
- The image height.This example shows how to create a new PSD image and fill it with a linear gradient brush.
String dir = "c:\\temp\\"; // Create a PSD image of 100x100 px. com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage(100, 100); try { // Define a blue-yellow 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(psdImage.getWidth(), psdImage.getHeight()), com.aspose.imaging.Color.getBlue(), com.aspose.imaging.Color.getYellow()); com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(psdImage); // Fill the entire image with the blue-yellow gradient. graphics.fillRectangle(gradientBrush, psdImage.getBounds()); psdImage.save(dir + "gradient.psd"); } finally { psdImage.dispose(); }
public PsdImage(int width, int height, IColorPalette colorPalette, short colorMode, short channelBitDepth, short channels, int psdVersion, short compression)
Creates new instance of psd image PsdImage
class with specified width,height, paletter, color mode, channels count and channels bit-length and specified compression mode parameters. Used to initialize empty psd image.
width
- The image width.height
- The image height.colorPalette
- The color palette.colorMode
- The color mode.channelBitDepth
- The PSD bit depth per channel.channels
- The PSD channels count.psdVersion
- The PSD version.compression
- The compression to use.This example shows how to create a grayscale 8-bit PSD image.
String dir = "c:\\temp\\"; com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage( 100, // Width 100, // Height null, // Without a palette com.aspose.imaging.fileformats.psd.ColorModes.Grayscale, // Desired color mode (short) 8, // Number of bits per channel (short) 1, // Number of channels com.aspose.imaging.fileformats.psd.PsdImage.DEFAULT_VERSION, // Default version is 6 com.aspose.imaging.fileformats.psd.CompressionMethod.RLE); // The RLE compression allows to reduce the size of the output image { // Define a blue-yellow 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(psdImage.getWidth(), psdImage.getHeight()), com.aspose.imaging.Color.getBlue(), com.aspose.imaging.Color.getYellow()); com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(psdImage); // Fill the entire image with the blue-yellow gradient. // Note that all colors will be transformed to the grayscale format because the image is grayscale. graphics.fillRectangle(gradientBrush, psdImage.getBounds()); psdImage.save(dir + "gradient.grayscale.psd"); }
public XmpPacketWrapper getXmpData()
Gets the XMP metadata.
getXmpData
in class RasterCachedMultipageImage
public void setXmpData(XmpPacketWrapper value)
Sets the XMP metadata.
setXmpData
in class RasterCachedMultipageImage
value
- The XMP metadata.public long getFileFormat()
Gets a value of file format
getFileFormat
in class Image
public boolean hasAlpha()
Gets the vertical resolution, in pixels per inch, of this RasterImage
.
true
if this instance has alpha; otherwise, false
.hasAlpha
in class RasterCachedMultipageImage
RasterImage
.The following example loads a PSD image and prints information about raw data format and alpha channel.
String dir = "c:\\temp\\"; String fileName = dir + "sample.psd"; com.aspose.imaging.Image image = com.aspose.imaging.Image.load(fileName); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // If at least one of the PSD layers has alpha channel, then the entire PSD image is considered to have alpha channel System.out.printf("ImageFile=%s, FileFormat=%s, HasAlpha=%s\r\n", fileName, psdImage.getRawDataFormat(), psdImage.hasAlpha()); int i = 0; for (com.aspose.imaging.fileformats.psd.layers.Layer layer : psdImage.getLayers()) { System.out.printf("Layer=%s, FileFormat=%s, HasAlpha=%s\r\n", ++i, layer.getRawDataFormat(), layer.hasAlpha()); } } finally { image.dispose(); } // The output may look like this: // ImageFile=c:\temp\sample.psd, FileFormat=Rgb, used channels: 8,8,8, HasAlpha=True // Layer=1, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False // Layer=2, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=True // Layer=3, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=True // Layer=4, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=True // Layer=5, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=True
public double getVerticalResolution()
Gets the vertical resolution, in pixels per inch, of this PsdImage
.
getVerticalResolution
in class RasterImage
PsdImageException
- ResolutionInfo resource not found and can not set proper resolution
Default value for PSD is 72, so if ResolutionInfoResource
wasn't found, this value is returned.
The following example shows how to set horizontal/vertical resolution of a PSD image.
String dir = "c:\\temp\\"; com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.psd"); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // Get horizontal and vertical resolution of the PsdImage. double horizontalResolution = psdImage.getHorizontalResolution(); double verticalResolution = psdImage.getVerticalResolution(); System.out.println("The horizontal resolution, in pixels per inch: " + horizontalResolution); System.out.println("The vertical resolution, in pixels per inch: " + verticalResolution); if (horizontalResolution != 96.0 || verticalResolution != 96.0) { // Use the SetResolution method for updating both resolution values in a single call. System.out.println("Set resolution values to 96 dpi"); psdImage.setResolution(96.0, 96.0); System.out.println("The horizontal resolution, in pixels per inch: " + psdImage.getHorizontalResolution()); System.out.println("The vertical resolution, in pixels per inch: " + psdImage.getVerticalResolution()); } } finally { image.dispose(); } // The output may look like this: // The horizontal resolution, in pixels per inch: 72.0 // The vertical resolution, in pixels per inch: 72.0 // Set resolution values to 96 dpi // The horizontal resolution, in pixels per inch: 72.0 // The vertical resolution, in pixels per inch: 72.0
public void setVerticalResolution(double value)
Sets the vertical resolution, in pixels per inch, of this PsdImage
.
setVerticalResolution
in class RasterImage
value
- The vertical resolution.
Default value for PSD is 72, so if ResolutionInfoResource
wasn't found, this value is returned.
PsdImageException
- ResolutionInfo resource not found and can not set proper resolutionpublic double getHorizontalResolution()
Gets the horizontal resolution, in pixels per inch, of this PsdImage
.
getHorizontalResolution
in class RasterImage
PsdImageException
- ResolutionInfo resource not found and can not set proper resolution
Default value for PSD is 72, so if ResolutionInfoResource
wasn't found, this value is returned.
The following example shows how to set horizontal/vertical resolution of a PSD image.
String dir = "c:\\temp\\"; com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.psd"); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // Get horizontal and vertical resolution of the PsdImage. double horizontalResolution = psdImage.getHorizontalResolution(); double verticalResolution = psdImage.getVerticalResolution(); System.out.println("The horizontal resolution, in pixels per inch: " + horizontalResolution); System.out.println("The vertical resolution, in pixels per inch: " + verticalResolution); if (horizontalResolution != 96.0 || verticalResolution != 96.0) { // Use the SetResolution method for updating both resolution values in a single call. System.out.println("Set resolution values to 96 dpi"); psdImage.setResolution(96.0, 96.0); System.out.println("The horizontal resolution, in pixels per inch: " + psdImage.getHorizontalResolution()); System.out.println("The vertical resolution, in pixels per inch: " + psdImage.getVerticalResolution()); } } finally { image.dispose(); } // The output may look like this: // The horizontal resolution, in pixels per inch: 72.0 // The vertical resolution, in pixels per inch: 72.0 // Set resolution values to 96 dpi // The horizontal resolution, in pixels per inch: 72.0 // The vertical resolution, in pixels per inch: 72.0
public void setHorizontalResolution(double value)
Sets the horizontal resolution, in pixels per inch, of this PsdImage
.
setHorizontalResolution
in class RasterImage
value
- The horizontal resolution.
Default value for PSD is 72, so if ResolutionInfoResource
wasn't found, this value is returned.
PsdImageException
- ResolutionInfo resource not found and can not set proper resolutionpublic StreamSource getRgbColorProfile()
The RGB color profile for CMYK PSD images. Must be in pair with CmykColorProfile for correct color conversion.
public void setRgbColorProfile(StreamSource value)
The RGB color profile for CMYK PSD images. Must be in pair with CmykColorProfile for correct color conversion.
value
- The RGB color profile.public StreamSource getCmykColorProfile()
The CMYK color profile for CMYK PSD images. Must be in pair with RgbColorProfile for correct color conversion.
public void setCmykColorProfile(StreamSource value)
The CMYK color profile for CMYK PSD images. Must be in pair with RgbColorProfile for correct color conversion.
value
- The CMYK color profile.public StreamSource getGrayColorProfile()
The GRAY (monochrome) color profile for Grayscale PSD images.
public void setGrayColorProfile(StreamSource value)
The GRAY (monochrome) color profile for Grayscale PSD images.
value
- The GRAY (monochrome) color profile.public short getColorMode()
Gets the color mode.
public void setColorMode(short value)
Sets the color mode.
value
- The color mode.public short getCompression()
Gets the compression method.
public int getChannelsCount()
Gets the PSD channels count.
public int getBitsPerChannel()
Gets the bits per channel.
public ResourceBlock[] getImageResources()
Gets the PSD image resources.
public void setImageResources(ResourceBlock[] value)
Sets the PSD image resources.
value
- The PSD image resources.public int getVersion()
Gets the version.
public void setVersion(int value)
Sets the version.
value
- The version.public int getWidth()
Gets the image width.
getWidth
in interface IObjectWithBounds
getWidth
in class RasterCachedMultipageImage
public int getHeight()
Gets the image height.
getHeight
in interface IObjectWithBounds
getHeight
in class RasterCachedMultipageImage
public int getBitsPerPixel()
Gets the image bits per pixel count.
getBitsPerPixel
in class RasterCachedMultipageImage
public int getPageCount()
Gets the page count.
Value: The page count.<autogeneratedoc></autogeneratedoc>
getPageCount
in interface IMultipageImage
getPageCount
in class RasterCachedMultipageImage
public Image[] getPages()
Gets the pages.
Value: The pages.<autogeneratedoc></autogeneratedoc>
getPages
in interface IMultipageImage
getPages
in class RasterCachedMultipageImage
public Image getDefaultPage()
Gets the default page.
Value: The default page.<autogeneratedoc></autogeneratedoc>
getDefaultPage
in interface IMultipageImage
getDefaultPage
in class RasterCachedMultipageImage
public Layer[] getLayers()
Gets the PSD layers.
Note that if there are no layers the other related information within layer and mask information section will not be preserved (layer masks, resources and etc).
public void setLayers(Layer[] value)
Sets the PSD layers.
value
- The PSD layers.
Note that if there are no layers the other related information within layer and mask information section will not be preserved (layer masks, resources and etc).
public LayerResource[] getGlobalLayerResources()
Gets the global layer resources.
public void setGlobalLayerResources(LayerResource[] value)
Sets the global layer resources.
value
- The global layer resources.public GlobalLayerMaskInfo getGlobalLayerMaskInfo()
Gets the global layer mask info.
public boolean hasTransparencyData()
Gets or sets a value indicating whether first alpha channel contains the transparency data for the merged result when specifying layers data.
true
if first alpha channel contains the transparency data for the merged result when specifying layers data; otherwise, false
.public void setTransparencyData(boolean value)
Sets a value indicating whether first alpha channel contains the transparency data for the merged result when specifying layers data.
value
- true
if first alpha channel contains the transparency data for the merged result when specifying layers data; otherwise, false
.public boolean hasTransparentColor()
Gets a value indicating whether image has transparent color.
hasTransparentColor
in class RasterCachedMultipageImage
public Layer getActiveLayer()
Gets the active layer.
TiffImageException
- There is no active layer and no layers in image.PsdImageException
- The active layer cannot be set as it belongs to another image.public void setActiveLayer(Layer value)
Sets the active layer.
value
- The active layer.TiffImageException
- There is no active layer and no layers in image.PsdImageException
- The active layer cannot be set as it belongs to another image.public boolean isFlatten()
Gets a value indicating whether psd image is flattened.
true
if this instance is flatten; otherwise, false
.public float getImageOpacity()
Gets opacity of this image.
Value: The opacity value between 0.0 (fully transparent) and 1.0 (fully opaque).getImageOpacity
in class RasterCachedMultipageImage
public PixelDataFormat getRawDataFormat()
Gets the raw data format.
getRawDataFormat
in class RasterImage
The following example loads a PSD image and prints information about raw data format and alpha channel.
String dir = "c:\\temp\\"; String fileName = dir + "sample.psd"; com.aspose.imaging.Image image = com.aspose.imaging.Image.load(fileName); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // If at least one of the PSD layers has alpha channel, then the entire PSD image is considered to have alpha channel System.out.printf("ImageFile=%s, FileFormat=%s, HasAlpha=%s\r\n", fileName, psdImage.getRawDataFormat(), psdImage.hasAlpha()); int i = 0; for (com.aspose.imaging.fileformats.psd.layers.Layer layer : psdImage.getLayers()) { System.out.printf("Layer=%s, FileFormat=%s, HasAlpha=%s\r\n", ++i, layer.getRawDataFormat(), layer.hasAlpha()); } } finally { image.dispose(); } // The output may look like this: // ImageFile=c:\temp\sample.psd, FileFormat=Rgb, used channels: 8,8,8, HasAlpha=True // Layer=1, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False // Layer=2, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=True // Layer=3, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=True // Layer=4, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=True // Layer=5, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=True
public final void addLayer(Layer layer)
Adds the layer.
layer
- The layer.public final Layer mergeLayers(Layer bottomLayer, Layer topLayer)
Merges the layers.
bottomLayer
- The bottom layer.topLayer
- The top layer.public final void flattenImage()
Flattens all layers.
This example shows how to add two general-purpose layers to a PSD image and then join them into one layer.
String dir = "c:\\temp\\"; // Create a PSD image of 100x100 px. com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage( 100, // Width 100, // Height null, // Without a palette com.aspose.imaging.fileformats.psd.ColorModes.Rgb, // Desired color mode (short) 8, // Number of bits per channel (short) 4, // Number of channels, R,G,B + Alpha com.aspose.imaging.fileformats.psd.PsdImage.DEFAULT_VERSION, // Default version is 6 com.aspose.imaging.fileformats.psd.CompressionMethod.RLE); // The RLE compression allows to reduce the size of the output image { // Add a new regular layer. This layer will be in front of the back layer. com.aspose.imaging.fileformats.psd.layers.Layer frontLayer = psdImage.addRegularLayer(); // Define a 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(frontLayer.getWidth(), frontLayer.getHeight()), com.aspose.imaging.Color.getBlue(), com.aspose.imaging.Color.getTransparent()); com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(frontLayer); // Fill the first layer with the blue-transparent gradient. graphics.fillRectangle(gradientBrush, frontLayer.getBounds()); // Add a new regular layer. This layer will be behind the front layer. com.aspose.imaging.fileformats.psd.layers.Layer backLayer = psdImage.addRegularLayer(); com.aspose.imaging.Graphics graphics2 = new com.aspose.imaging.Graphics(backLayer); // Define a yellow-transparent gradient. com.aspose.imaging.brushes.LinearGradientBrush gradientBrush2 = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(backLayer.getWidth(), 0), new com.aspose.imaging.Point(0, backLayer.getHeight()), com.aspose.imaging.Color.getYellow(), com.aspose.imaging.Color.getTransparent()); // Fill the second layer with the yellow-transparent gradient. graphics2.fillRectangle(gradientBrush2, backLayer.getBounds()); // Merge all the image's layers into one layer. psdImage.flattenImage(); psdImage.save(dir + "flatten.psd"); }
public final Layer addRegularLayer()
Adds a new regular layer.
This example shows how to add two general-purpose layers to a PSD image and then join them into one layer.
String dir = "c:\\temp\\"; // Create a PSD image of 100x100 px. com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage( 100, // Width 100, // Height null, // Without a palette com.aspose.imaging.fileformats.psd.ColorModes.Rgb, // Desired color mode (short) 8, // Number of bits per channel (short) 4, // Number of channels, R,G,B + Alpha com.aspose.imaging.fileformats.psd.PsdImage.DEFAULT_VERSION, // Default version is 6 com.aspose.imaging.fileformats.psd.CompressionMethod.RLE); // The RLE compression allows to reduce the size of the output image { // Add a new regular layer. This layer will be in front of the back layer. com.aspose.imaging.fileformats.psd.layers.Layer frontLayer = psdImage.addRegularLayer(); // Define a 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(frontLayer.getWidth(), frontLayer.getHeight()), com.aspose.imaging.Color.getBlue(), com.aspose.imaging.Color.getTransparent()); com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(frontLayer); // Fill the first layer with the blue-transparent gradient. graphics.fillRectangle(gradientBrush, frontLayer.getBounds()); // Add a new regular layer. This layer will be behind the front layer. com.aspose.imaging.fileformats.psd.layers.Layer backLayer = psdImage.addRegularLayer(); com.aspose.imaging.Graphics graphics2 = new com.aspose.imaging.Graphics(backLayer); // Define a yellow-transparent gradient. com.aspose.imaging.brushes.LinearGradientBrush gradientBrush2 = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(backLayer.getWidth(), 0), new com.aspose.imaging.Point(0, backLayer.getHeight()), com.aspose.imaging.Color.getYellow(), com.aspose.imaging.Color.getTransparent()); // Fill the second layer with the yellow-transparent gradient. graphics2.fillRectangle(gradientBrush2, backLayer.getBounds()); // Merge all the image's layers into one layer. psdImage.flattenImage(); psdImage.save(dir + "flatten.psd"); }
public final TextLayer addTextLayer(String text, Rectangle rect)
Adds a new Text layer.
text
- The layer's text.rect
- The layer's rectangle.This example shows how to add a text layer to a PSD image.
String dir = "c:\\temp\\"; // Create a PSD image of 100x100 px. com.aspose.imaging.fileformats.psd.PsdImage psdImage = new com.aspose.imaging.fileformats.psd.PsdImage(100, 100); try { com.aspose.imaging.fileformats.psd.layers.TextLayer textLayer = psdImage.addTextLayer("Hello World!", psdImage.getBounds()); psdImage.save(dir + "textlayer.psd"); } finally { psdImage.dispose(); }
public final CurvesLayer addCurvesAdjustmentLayer()
Adds the Curves Adjustment layer.
CurvesLayer
Layerpublic final ExposureLayer addExposureAdjustmentLayer()
public final ExposureLayer addExposureAdjustmentLayer(float exposure)
public final ExposureLayer addExposureAdjustmentLayer(float exposure, float offset)
public final ExposureLayer addExposureAdjustmentLayer(float exposure, float offset, float gammaCorrection)
Adds the exposure adjustment layer.
exposure
- The exposure.offset
- The offset.gammaCorrection
- The gamma correction.public final HueSaturationLayer addHueSaturationAdjustmentLayer()
Adds the hue/saturation adjustment layer.
public final LevelsLayer addLevelsAdjustmentLayer()
Adds the Levels adjustment layer.
public final PhotoFilterLayer addPhotoFilterLayer(Color color)
Adds the photofilter layer.
color
- The color.public final ExposureLayer addExposureLayer()
public final ExposureLayer addExposureLayer(float exposure)
public final ExposureLayer addExposureLayer(float exposure, float offset)
public final ExposureLayer addExposureLayer(float exposure, float offset, float gammaCorrection)
Adds the exposure adjustment layer.
exposure
- The exposure.offset
- The offset.gammaCorrection
- The gamma correction.public final ChannelMixerLayer addChannelMixerAdjustmentLayer()
Adds the channel mixer adjustment layer with default parameters
public final BrightnessContrastLayer addBrightnessContrastAdjustmentLayer(int brightness, int contrast)
Adds the brightness/contrast adjustment layer.
brightness
- The brightness.contrast
- The contrast.public LayerGroup addLayerGroup(String groupName, int index, boolean startBehaviour)
Adds the layer group.
groupName
- Name of the group.index
- The index of the layer to insert after.startBehaviour
- if set to true
[start behaviour] than group will be in open state on start up, otherwise in minimized state.public void resizeWidthProportionally(int newWidth, int resizeType)
Resizes the width proportionally.
resizeWidthProportionally
in class RasterCachedMultipageImage
newWidth
- The new width.resizeType
- Type of the resize.This example loads a PSD image and resizes it proportionally using various resizing methods. Only the width is specified, the height is calculated automatically.
String dir = "c:\\temp\\"; com.aspose.imaging.fileformats.psd.PsdImage image = (com.aspose.imaging.fileformats.psd.PsdImage) com.aspose.imaging.Image.load(dir + "sample.psd"); try { // Scale up by 2 times using Nearest Neighbour resampling. image.resizeWidthProportionally(image.getWidth() * 2, com.aspose.imaging.ResizeType.NearestNeighbourResample); // Save to PNG with the default options. image.save(dir + "upsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = (com.aspose.imaging.fileformats.psd.PsdImage) com.aspose.imaging.Image.load(dir + "sample.psd"); try { // Scale down by 2 times using Nearest Neighbour resampling. image.resizeWidthProportionally(image.getWidth() / 2, com.aspose.imaging.ResizeType.NearestNeighbourResample); // Save to PNG with the default options. image.save(dir + "downsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = (com.aspose.imaging.fileformats.psd.PsdImage) com.aspose.imaging.Image.load(dir + "sample.psd"); try { // Scale up by 2 times using Bilinear resampling. image.resizeWidthProportionally(image.getWidth() * 2, com.aspose.imaging.ResizeType.BilinearResample); // Save to PNG with the default options. image.save(dir + "upsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = (com.aspose.imaging.fileformats.psd.PsdImage) com.aspose.imaging.Image.load(dir + "sample.psd"); try { // Scale down by 2 times using Bilinear resampling. image.resizeWidthProportionally(image.getWidth() / 2, com.aspose.imaging.ResizeType.BilinearResample); // Save to PNG with the default options. image.save(dir + "downsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); }
public void resizeHeightProportionally(int newHeight, int resizeType)
Resizes the width proportionally.
resizeHeightProportionally
in class RasterCachedMultipageImage
newHeight
- The new height.resizeType
- Type of the resize.This example loads a PSD image and resizes it proportionally using various resizing methods. Only the height is specified, the width is calculated automatically.
String dir = "c:\\temp\\"; com.aspose.imaging.fileformats.psd.PsdImage image = (com.aspose.imaging.fileformats.psd.PsdImage) com.aspose.imaging.Image.load(dir + "sample.psd"); try { // Scale up by 2 times using Nearest Neighbour resampling. image.resizeHeightProportionally(image.getHeight() * 2, com.aspose.imaging.ResizeType.NearestNeighbourResample); // Save to PNG with the default options. image.save(dir + "upsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = (com.aspose.imaging.fileformats.psd.PsdImage) com.aspose.imaging.Image.load(dir + "sample.psd"); try { // Scale down by 2 times using Nearest Neighbour resampling. image.resizeHeightProportionally(image.getHeight() / 2, com.aspose.imaging.ResizeType.NearestNeighbourResample); // Save to PNG with the default options. image.save(dir + "downsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = (com.aspose.imaging.fileformats.psd.PsdImage) com.aspose.imaging.Image.load(dir + "sample.psd"); try { // Scale up by 2 times using Bilinear resampling. image.resizeHeightProportionally(image.getHeight() * 2, com.aspose.imaging.ResizeType.BilinearResample); // Save to PNG with the default options. image.save(dir + "upsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = (com.aspose.imaging.fileformats.psd.PsdImage) com.aspose.imaging.Image.load(dir + "sample.psd"); try { // Scale down by 2 times using Bilinear resampling. image.resizeHeightProportionally(image.getHeight() / 2, com.aspose.imaging.ResizeType.BilinearResample); // Save to PNG with the default options. image.save(dir + "downsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); }
public void filter(Rectangle rectangle, FilterOptionsBase options)
Filters the specified rectangle.
filter
in class RasterCachedMultipageImage
rectangle
- The rectangle.options
- The options.The following example applies various types of filters to a PSD image.
String dir = "c:\\temp\\"; com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.psd"); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // Apply a median filter with a rectangle size of 5 to the entire image. psdImage.filter(psdImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.MedianFilterOptions(5)); psdImage.save(dir + "sample.MedianFilter.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = com.aspose.imaging.Image.load(dir + "sample.psd"); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // Apply a bilateral smoothing filter with a kernel size of 5 to the entire image. psdImage.filter(psdImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.BilateralSmoothingFilterOptions(5)); psdImage.save(dir + "sample.BilateralSmoothingFilter.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = com.aspose.imaging.Image.load(dir + "sample.psd"); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image. psdImage.filter(psdImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.GaussianBlurFilterOptions(5, 4.0)); psdImage.save(dir + "sample.GaussianBlurFilter.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = com.aspose.imaging.Image.load(dir + "sample.psd"); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image. psdImage.filter(psdImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.GaussWienerFilterOptions(5, 4.0)); psdImage.save(dir + "sample.GaussWienerFilter.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = com.aspose.imaging.Image.load(dir + "sample.psd"); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // Apply a motion wiener filter with a length of 5, a smooth value of 4.0 and an angle of 90.0 degrees to the entire image. psdImage.filter(psdImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.MotionWienerFilterOptions(10, 1.0, 90.0)); psdImage.save(dir + "sample.MotionWienerFilter.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); } image = com.aspose.imaging.Image.load(dir + "sample.psd"); try { com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image; // Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image. psdImage.filter(psdImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.SharpenFilterOptions(5, 4.0)); psdImage.save(dir + "sample.SharpenFilter.png", new com.aspose.imaging.imageoptions.PngOptions()); } finally { image.dispose(); }
public void resize(int newWidth, int newHeight, int resizeType)
Resizes the image.
resize
in class RasterCachedMultipageImage
newWidth
- The new width.newHeight
- The new height.resizeType
- The resize type.public void crop(int leftShift, int rightShift, int topShift, int bottomShift)
Crop image with shifts.
crop
in class RasterCachedMultipageImage
leftShift
- The left shift.rightShift
- The right shift.topShift
- The top shift.bottomShift
- The bottom shift.public void crop(Rectangle rectangle)
Cropping the image.
crop
in class RasterCachedMultipageImage
rectangle
- The rectangle.public void rotate(float angle, boolean resizeProportionally, Color backgroundColor)
!:RasterCahcedMultipageImage.Rotate
image around the center.
rotate
in class RasterCachedMultipageImage
angle
- The rotate angle in degrees. Positive values will rotate clockwise.resizeProportionally
- if set to true
you will have your image size changed
according to rotated rectangle (corner points) projections in other
case that leaves dimensions untouched and only
image contents are rotated.backgroundColor
- Color of the background.public void rotateFlip(int rotateFlipType)
Rotates, flips, or rotates and flips the Active frame only.
rotateFlip
in class RasterCachedMultipageImage
rotateFlipType
- The rotate flip type.RotateFlipType