Image Class
Summary: The image is the base class for all type of images.
Module: aspose.psd
Full Name: aspose.psd.Image
Inheritance: IObjectWithBounds, DataStreamSupporter
Aspose.PSD Version: 24.12.0
Properties
| Name | Type | Access | Description | 
|---|---|---|---|
| auto_adjust_palette | bool | r/w | Gets or sets a value indicating whether automatic adjust palette. | 
| background_color | Color | r/w | Gets or sets a value for the background color. | 
| bits_per_pixel | int | r | Gets the image bits per pixel count. | 
| bounds | Rectangle | r | Gets the image bounds. | 
| buffer_size_hint | int | r/w | Gets or sets the buffer size hint which is defined max allowed size for all internal buffers. | 
| container | Image | r | Gets the Image container. | 
| data_stream_container | StreamContainer | r | Gets the object’s data stream. | 
| disposed | bool | r | Gets a value indicating whether this instance is disposed. | 
| file_format | FileFormat | r | Gets a value of file format | 
| has_background_color | bool | r/w | Gets or sets a value indicating whether image has background color. | 
| height | int | r | Gets the image height. | 
| interrupt_monitor | InterruptMonitor | r/w | Gets or sets the interrupt monitor. | 
| is_cached | bool | r | Gets a value indicating whether object’s data is cached currently and no data reading is required. | 
| palette | IColorPalette | r/w | Gets or sets the color palette. The color palette is not used when pixels are represented directly. | 
| size | Size | r | Gets the image size. | 
| use_palette | bool | r | Gets a value indicating whether the image palette is used. | 
| width | int | r | Gets the image width. | 
Methods
| Name | Description | 
|---|---|
| cache_data() | Caches the data and ensures no additional data loading will be performed from the underlying DataStreamSupporter.data_stream_container. | 
| can_load(file_path) | Determines whether image can be loaded from the specified file path. | 
| can_load(file_path, load_options) | Determines whether image can be loaded from the specified file path and optionally using the specified open options. | 
| can_load(stream) | Determines whether image can be loaded from the specified stream. | 
| can_load(stream, load_options) | Determines whether image can be loaded from the specified stream and optionally using the specified | 
| can_save(options) | Determines whether image can be saved to the specified file format represented by the passed save options. | 
| create(image_options, width, height) | Creates a new image using the specified create options. | 
| get_default_options(args) | Gets the default options. | 
| get_file_format(file_path) | Gets the file format. | 
| get_file_format(stream) | Gets the file format. | 
| get_fitting_rectangle(rectangle, pixels, width, height) | Gets rectangle which fits the current image. | 
| get_fitting_rectangle(rectangle, width, height) | Gets rectangle which fits the current image. | 
| get_original_options() | Gets the options based on the original file settings. This can be helpful to keep bit-depth and other parameters of the original image unchanged. For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the DataStreamSupporter.save(file_path) method, the output PNG image with 8-bit per pixel will be produced. To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them to the Image.save(file_path, options) method as the second parameter. | 
| get_proportional_height(width, height, new_width) | Gets a proportional height. | 
| get_proportional_width(width, height, new_height) | Gets a proportional width. | 
| load(file_path) | Loads a new image from the specified file. | 
| load(file_path, load_options) | Loads a new image from the specified file. | 
| load(stream) | Loads a new image from the specified stream. | 
| load(stream, load_options) | Loads a new image from the specified stream. | 
| resize(new_width, new_height) | Resizes the image. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used. | 
| resize(new_width, new_height, resize_type) | Resizes the image. | 
| resize(new_width, new_height, settings) | Resizes the image. | 
| resize_height_proportionally(new_height) | Resizes the height proportionally. | 
| resize_height_proportionally(new_height, resize_type) | Resizes the height proportionally. | 
| resize_height_proportionally(new_height, settings) | Resizes the height proportionally. | 
| resize_width_proportionally(new_width) | Resizes the width proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used. | 
| resize_width_proportionally(new_width, resize_type) | Resizes the width proportionally. | 
| resize_width_proportionally(new_width, settings) | Resizes the width proportionally. | 
| rotate_flip(rotate_flip_type) | Rotates, flips, or rotates and flips the image. | 
| save() | Saves the image data to the underlying stream. | 
| save(file_path) | Saves the object’s data to the specified file location. | 
| save(file_path, options) | Saves the object’s data to the specified file location in the specified file format according to save options. | 
| save(file_path, options, bounds_rectangle) | Saves the object’s data to the specified file location in the specified file format according to save options. | 
| save(file_path, over_write) | Saves the object’s data to the specified file location. | 
| save(stream) | Saves the object’s data to the specified stream. | 
| save(stream, options_base) | Saves the image’s data to the specified stream in the specified file format according to save options. | 
| save(stream, options_base, bounds_rectangle) | Saves the image’s data to the specified stream in the specified file format according to save options. | 
| set_palette(palette, update_colors) | Sets the image palette. | 
Method: can_load(file_path) [static]
 can_load(file_path) 
Determines whether image can be loaded from the specified file path.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| file_path | string | The file path. | 
Returns
| Type | Description | 
|---|---|
| bool | 
Method: can_load(file_path, load_options) [static]
 can_load(file_path, load_options) 
Determines whether image can be loaded from the specified file path and optionally using the specified open options.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| file_path | string | The file path. | 
| load_options | LoadOptions | The load options. | 
Returns
| Type | Description | 
|---|---|
| bool | 
Method: can_load(stream) [static]
 can_load(stream) 
Determines whether image can be loaded from the specified stream.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| stream | _io.BufferedRandom | The stream to load from. | 
Returns
| Type | Description | 
|---|---|
| bool | 
Method: can_load(stream, load_options) [static]
 can_load(stream, load_options) 
Determines whether image can be loaded from the specified stream and optionally using the specified 
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| stream | _io.BufferedRandom | The stream to load from. | 
| load_options | LoadOptions | The load options. | 
Returns
| Type | Description | 
|---|---|
| bool | 
Method: can_save(options)
 can_save(options) 
Determines whether image can be saved to the specified file format represented by the passed save options.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| options | ImageOptionsBase | The save options to use. | 
Returns
| Type | Description | 
|---|---|
| bool | 
Method: create(image_options, width, height) [static]
 create(image_options, width, height) 
Creates a new image using the specified create options.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| image_options | ImageOptionsBase | The image options. | 
| width | int | The width. | 
| height | int | The height. | 
Returns
| Type | Description | 
|---|---|
| Image | The newly created image. | 
Method: get_default_options(args)
 get_default_options(args) 
Gets the default options.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| args | object | The arguments. | 
Returns
| Type | Description | 
|---|---|
| ImageOptionsBase | Default options | 
Method: get_file_format(file_path) [static]
 get_file_format(file_path) 
Gets the file format.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| file_path | string | The file path. | 
Returns
| Type | Description | 
|---|---|
| FileFormat | The determined file format. | 
Method: get_file_format(stream) [static]
 get_file_format(stream) 
Gets the file format.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| stream | _io.BufferedRandom | The stream. | 
Returns
| Type | Description | 
|---|---|
| FileFormat | The determined file format. | 
Method: get_fitting_rectangle(rectangle, pixels, width, height) [static]
 get_fitting_rectangle(rectangle, pixels, width, height) 
Gets rectangle which fits the current image.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| rectangle | Rectangle | The rectangle to get fitting rectangle for. | 
| pixels | int | The 32-bit ARGB pixels. | 
| width | int | The object width. | 
| height | int | The object height. | 
Returns
| Type | Description | 
|---|---|
| Rectangle | The fitting rectangle or exception if no fitting rectangle can be found. | 
Method: get_fitting_rectangle(rectangle, width, height) [static]
 get_fitting_rectangle(rectangle, width, height) 
Gets rectangle which fits the current image.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| rectangle | Rectangle | The rectangle to get fitting rectangle for. | 
| width | int | The object width. | 
| height | int | The object height. | 
Returns
| Type | Description | 
|---|---|
| Rectangle | The fitting rectangle or exception if no fitting rectangle can be found. | 
Method: get_original_options()
 get_original_options() 
Gets the options based on the original file settings.
This can be helpful to keep bit-depth and other parameters of the original image unchanged.
For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the
DataStreamSupporter.save(file_path) method, the output PNG image with 8-bit per pixel will be produced.
To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them
to the Image.save(file_path, options) method as the second parameter.
Returns
| Type | Description | 
|---|---|
| ImageOptionsBase | The options based on the original file settings. | 
Method: get_proportional_height(width, height, new_width) [static]
 get_proportional_height(width, height, new_width) 
Gets a proportional height.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| width | int | The width. | 
| height | int | The height. | 
| new_width | int | The new width. | 
Returns
| Type | Description | 
|---|---|
| int | The proportional height. | 
Method: get_proportional_width(width, height, new_height) [static]
 get_proportional_width(width, height, new_height) 
Gets a proportional width.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| width | int | The width. | 
| height | int | The height. | 
| new_height | int | The new height. | 
Returns
| Type | Description | 
|---|---|
| int | The proportional width. | 
Method: load(file_path) [static]
 load(file_path) 
Loads a new image from the specified file.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| file_path | string | The file path to load image from. | 
Returns
| Type | Description | 
|---|---|
| Image | The loaded image. | 
Method: load(file_path, load_options) [static]
 load(file_path, load_options) 
Loads a new image from the specified file.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| file_path | string | The file path to load image from. | 
| load_options | LoadOptions | The load options. | 
Returns
| Type | Description | 
|---|---|
| Image | The loaded image. | 
Method: load(stream) [static]
 load(stream) 
Loads a new image from the specified stream.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| stream | _io.BufferedRandom | The stream to load image from. | 
Returns
| Type | Description | 
|---|---|
| Image | The loaded image. | 
Method: load(stream, load_options) [static]
 load(stream, load_options) 
Loads a new image from the specified stream.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| stream | _io.BufferedRandom | The stream to load image from. | 
| load_options | LoadOptions | The load options. | 
Returns
| Type | Description | 
|---|---|
| Image | The loaded image. | 
Method: resize(new_width, new_height)
 resize(new_width, new_height) 
Resizes the image. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| new_width | int | The new width. | 
| new_height | int | The new height. | 
Method: resize(new_width, new_height, resize_type)
 resize(new_width, new_height, resize_type) 
Resizes the image.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| new_width | int | The new width. | 
| new_height | int | The new height. | 
| resize_type | ResizeType | The resize type. | 
Method: resize(new_width, new_height, settings)
 resize(new_width, new_height, settings) 
Resizes the image.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| new_width | int | The new width. | 
| new_height | int | The new height. | 
| settings | ImageResizeSettings | The resize settings. | 
Method: resize_height_proportionally(new_height)
 resize_height_proportionally(new_height) 
Resizes the height proportionally.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| new_height | int | The new height. | 
Method: resize_height_proportionally(new_height, resize_type)
 resize_height_proportionally(new_height, resize_type) 
Resizes the height proportionally.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| new_height | int | The new height. | 
| resize_type | ResizeType | Type of the resize. | 
Method: resize_height_proportionally(new_height, settings)
 resize_height_proportionally(new_height, settings) 
Resizes the height proportionally.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| new_height | int | The new height. | 
| settings | ImageResizeSettings | The image resize settings. | 
Method: resize_width_proportionally(new_width)
 resize_width_proportionally(new_width) 
Resizes the width proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| new_width | int | The new width. | 
Method: resize_width_proportionally(new_width, resize_type)
 resize_width_proportionally(new_width, resize_type) 
Resizes the width proportionally.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| new_width | int | The new width. | 
| resize_type | ResizeType | Type of the resize. | 
Method: resize_width_proportionally(new_width, settings)
 resize_width_proportionally(new_width, settings) 
Resizes the width proportionally.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| new_width | int | The new width. | 
| settings | ImageResizeSettings | The image resize settings. | 
Method: rotate_flip(rotate_flip_type)
 rotate_flip(rotate_flip_type) 
Rotates, flips, or rotates and flips the image.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| rotate_flip_type | RotateFlipType | Type of the rotate flip. | 
Method: save(file_path)
 save(file_path) 
Saves the object’s data to the specified file location.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| file_path | string | The file path to save the object’s data to. | 
Method: save(file_path, options)
 save(file_path, options) 
Saves the object’s data to the specified file location in the specified file format according to save options.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| file_path | string | The file path. | 
| options | ImageOptionsBase | The options. | 
Method: save(file_path, options, bounds_rectangle)
 save(file_path, options, bounds_rectangle) 
Saves the object’s data to the specified file location in the specified file format according to save options.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| file_path | string | The file path. | 
| options | ImageOptionsBase | The options. | 
| bounds_rectangle | Rectangle | The destination image bounds rectangle. Set the empty rectangle for use sourse bounds. | 
Method: save(file_path, over_write)
 save(file_path, over_write) 
Saves the object’s data to the specified file location.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| file_path | string | The file path to save the object’s data to. | 
| over_write | bool | if set to | 
Method: save(stream)
 save(stream) 
Saves the object’s data to the specified stream.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| stream | _io.BufferedRandom | The stream to save the object’s data to. | 
Method: save(stream, options_base)
 save(stream, options_base) 
Saves the image’s data to the specified stream in the specified file format according to save options.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| stream | _io.BufferedRandom | The stream to save the image’s data to. | 
| options_base | ImageOptionsBase | The save options. | 
Method: save(stream, options_base, bounds_rectangle)
 save(stream, options_base, bounds_rectangle) 
Saves the image’s data to the specified stream in the specified file format according to save options.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| stream | _io.BufferedRandom | The stream to save the image’s data to. | 
| options_base | ImageOptionsBase | The save options. | 
| bounds_rectangle | Rectangle | The destination image bounds rectangle. Set the empty rectangle for use source bounds. | 
Method: set_palette(palette, update_colors)
 set_palette(palette, update_colors) 
Sets the image palette.
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| palette | IColorPalette | The palette to set. | 
| update_colors | bool | if set to |