SmartObjectLayer Class

Summary: Defines the SmartObjectLayer class that contains embedded in the PSD file or linked smart object in the external file.
With Smart Objects, you can:
Perform nondestructive transforms. You can scale, rotate, skew, distort, perspective transform, or warp a layer
without losing original image data or quality because the transforms don�t affect the original data.
Work with vector data, such as vector artwork from Illustrator, that otherwise would be rasterized.
Perform nondestructive filtering. You can edit filters applied to Smart Objects at any time.
Edit one Smart Object and automatically update all its linked instances.
Apply a layer mask that�s either linked or unlinked to the Smart Object layer.
Try various designs with low-resolution placeholder images that you later replace with final versions.
In Adobe� Photoshop�, you can embed the contents of an image into a PSD document.
More information is here:
A layer with an embedded smart object contains placed (PlLd) and SoLd resources with smart object properties.
The PlLd resource can be alone for PSD versions older then 10.
These resources contain UniqueId of the LiFdDataSource in the global Lnk2Resource with the embedded filename
and other parameters, including the embedded file contents in the original format as a byte array.

Module: aspose.psd.fileformats.psd.layers.smartobjects

Full Name: aspose.psd.fileformats.psd.layers.smartobjects.SmartObjectLayer

Inheritance: IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, Layer

Aspose.PSD Version: 24.9.0

Constructors

NameDescription
SmartObjectLayer(stream)Initializes a new instance of the SmartObjectLayer class.

Properties

NameTypeAccessDescription
BLEND_SIGNATURE [static]intr
LAYER_HEADER_SIZE [static]intr
auto_adjust_paletteboolr/w
background_colorColorr/w
bits_per_pixelintr
blend_clipped_elementsboolr/w
blend_mode_keyBlendModer/w
blend_mode_signatureintr
blending_optionsBlendingOptionsr
bottomintr/w
boundsRectanglerGets the object bounds.
buffer_size_hintintr/w
channel_informationChannelInformation[]r/w
channels_countushortr
clippingbyter/w
containerImager
content_typeSmartObjectTyperGets the type of the smart object layer content.
The embedded smart object contents is the embedded raw image file: LiFdDataSource.data.
The linked smart object contents is the raw contents of the linked image file if it is available: LiFeDataSource.
We do not support loading from the Adobe� Photoshop� �� Graphics Library when LinkDataSource.is_library_link is true.
For regular link files, at first, we use LiFeDataSource.relative_path to look for the file relatively
to the source image path None,
if it is not available we look at LiFeDataSource.full_path,
if not then we look for the link file in the same directory where our image is: None.
contentsbyter/wGets or sets the smart object layer contents.
The embedded smart object contents is the embedded raw image file: LiFdDataSource.data and its properties.
The linked smart object contents is the raw content of the linked image file if it is available and its properties: LiFeDataSource.
We do not support loading from the Adobe� Photoshop� �� Graphics Library when LinkDataSource.is_library_link is true.
For regular link files, at first, we use LiFeDataSource.relative_path to look for the file relatively
to the source image path None,
if it is not available we look at LiFeDataSource.full_path,
if not then we look for the link file in the same directory where our image is: None.
contents_boundsRectangler/wGets or sets the smart object content’s bounds.
contents_sourceLinkDataSourcer/wGets or sets the smart object content’s source.
data_stream_containerStreamContainerr
display_namestringr/w
disposedboolr
extra_lengthintr
file_formatFileFormatr
fill_opacityintr/w
fillerbyter/w
flagsLayerFlagsr/w
has_alphaboolr
has_background_colorboolr/w
has_transparent_colorboolr/w
heightintrGets the object height.
horizontal_resolutiondoubler/w
image_opacityfloatr
interrupt_monitorInterruptMonitorr/w
is_cachedboolr
is_raw_data_availableboolrGets a value indicating whether raw data loading is supported.
is_visibleboolr/w
is_visible_in_groupboolr
layer_blending_ranges_dataLayerBlendingRangesDatar/w
layer_creation_date_timedatetimer/w
layer_lockLayerLockTyper/w
layer_mask_dataLayerMaskDatar/w
layer_optionsPsdOptionsr
leftintr/w
lengthintr
namestringr/wGets or sets the name of the text layer.
opacitybyter/w
paletteIColorPaletter/w
premultiply_componentsboolr/w
raw_custom_color_converterIColorConverterr/w
raw_data_formatPixelDataFormatr
raw_data_settingsRawDataSettingsrGets the current raw data settings. Note when using these settings the data loads without conversion.
raw_fallback_indexintr/w
raw_indexed_color_converterIIndexedColorConverterr/w
raw_line_sizeintr
resourcesLayerResource[]r/w
rightintr/w
sheet_color_highlightSheetColorHighlightEnumr/w
sizeSizerGets the object size.
smart_filtersSmartFiltersrGets the smart filters.
smart_object_providerSmartObjectProviderrGets the smart object provider.
topintr/w
transparent_colorColorr/w
update_xmp_databoolr/w
use_paletteboolr
use_raw_databoolr/w
vertical_resolutiondoubler/w
warp_settingsWarpSettingsr/wIt gets or sets Warp parameters that was set or get from resource (default)
widthintrGets the object width.
xmp_dataXmpPacketWrapperr/w

Methods

NameDescription
add_layer_mask(layer_mask)
adjust_brightness(brightness)
adjust_contrast(contrast)
adjust_gamma(gamma)
adjust_gamma(gamma_red, gamma_green, gamma_blue)
binarize_bradley(brightness_difference)
binarize_bradley(brightness_difference, window_size)
binarize_fixed(threshold)
binarize_otsu()
cache_data()
can_load(file_path)
can_load(file_path, load_options)
can_load(stream)
can_load(stream, load_options)
can_save(options)
convert_to_linked(linked_path)Converts this embedded smart object to a linked smart object.
create(image_options, width, height)
crop(left_shift, right_shift, top_shift, bottom_shift)
crop(rectangle)
dither(dithering_method, bits_count)
dither(dithering_method, bits_count, custom_palette)
draw_image(location, image)
duplicate_layer()Creates a new smart object layer by coping this one.
Notice that for embedded smart objects the embedded image is shared.
If you want to copy the embedded image use SmartObjectLayer.new_smart_object_via_copy() method.
embed_linked()Embeds the linked smart object in this layer.
export_contents(file_path)Exports the embedded or linked contents to a file.
filter(rectangle, options)
get_argb_32_pixel(x, y)
get_default_argb_32_pixels(rectangle)
get_default_options(args)
get_default_pixels(rectangle, partial_pixel_loader)
get_default_raw_data(rectangle, partial_raw_data_loader, raw_data_settings)
get_default_raw_data(rectangle, raw_data_settings)
get_file_format(file_path)
get_file_format(stream)
get_fitting_rectangle(rectangle, pixels, width, height)
get_fitting_rectangle(rectangle, width, height)
get_modify_date(use_default)
get_original_options()
get_pixel(x, y)
get_proportional_height(width, height, new_width)
get_proportional_width(width, height, new_height)
get_skew_angle()
grayscale()
load(file_path)
load(file_path, load_options)
load(stream)
load(stream, load_options)
load_argb_32_pixels(rectangle)
load_argb_64_pixels(rectangle)
load_cmyk_32_pixels(rectangle)
load_cmyk_pixels(rectangle)
load_contents(options)Gets the embedded or linked image contents of the smart object layer.
load_partial_argb_32_pixels(rectangle, partial_pixel_loader)Loads 32-bit ARGB pixels partially (by blocks).
load_partial_pixels(desired_rectangle, pixel_loader)
load_pixels(rectangle)
load_raw_data(rectangle, dest_image_bounds, raw_data_settings, raw_data_loader)
load_raw_data(rectangle, raw_data_settings, raw_data_loader)Loads raw data.
merge_layer_to(layer_to_merge_into)
new_smart_object_via_copy()Creates a new smart object layer by coping this one.
Reproduces Layer -> Smart Objects -> New Smart Object via Copy functionality of Adobe� Photoshop�.
Notice that it is enabled only for embedded smart objects because the embedded image is also copied.
If you want to share the embedded image use SmartObjectLayer.duplicate_layer() method.
normalize_angle()
normalize_angle(resize_proportionally, background_color)
read_argb_32_scan_line(scan_line_index)
read_scan_line(scan_line_index)
relink_to_file(linked_path)Re-links the linked smart object to a new file.
There is no need to call UpdateModifiedContent method afterwards.
replace_color(old_color, old_color_diff, new_color)
replace_color(old_color_argb, old_color_diff, new_color_argb)
replace_contents(image)Replaces the smart object contents embedded in the smart object layer.
replace_contents(image, resolution)Replaces the smart object contents embedded in the smart object layer.
replace_contents(linked_path)Replaces the contents with a file.
There is no need to call UpdateModifiedContent method afterwards.
replace_contents(linked_path, resolution)Replaces the contents with a file.
There is no need to call UpdateModifiedContent method afterwards.
replace_non_transparent_colors(new_color)
replace_non_transparent_colors(new_color_argb)
resize(new_width, new_height)
resize(new_width, new_height, resize_type)
resize(new_width, new_height, settings)
resize_height_proportionally(new_height)
resize_height_proportionally(new_height, resize_type)
resize_height_proportionally(new_height, settings)
resize_width_proportionally(new_width)
resize_width_proportionally(new_width, resize_type)
resize_width_proportionally(new_width, settings)
rotate(angle)
rotate(angle, resize_proportionally, background_color)
rotate_flip(rotate_flip_type)
save()
save(file_path)
save(file_path, options)
save(file_path, options, bounds_rectangle)
save(file_path, over_write)
save(stream)
save(stream, options_base)
save(stream, options_base, bounds_rectangle)
save_argb_32_pixels(rectangle, pixels)
save_cmyk_32_pixels(rectangle, pixels)
save_cmyk_pixels(rectangle, pixels)
save_pixels(rectangle, pixels)
save_raw_data(data, data_offset, rectangle, raw_data_settings)
set_argb_32_pixel(x, y, argb_32_color)
set_palette(palette, update_colors)
set_pixel(x, y, color)
set_resolution(dpi_x, dpi_y)
shallow_copy()
to_bitmap()
update_modified_content()Updates the smart object layer image cache with the modified content.
write_argb_32_scan_line(scan_line_index, argb_32_pixels)
write_scan_line(scan_line_index, pixels)

Constructor: SmartObjectLayer(stream)

 SmartObjectLayer(stream) 

Initializes a new instance of the SmartObjectLayer class.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream of items

Method: can_load(file_path) [static]

 can_load(file_path) 

Parameters:

ParameterTypeDescription
file_pathstring

Returns

TypeDescription
bool

Method: can_load(file_path, load_options) [static]

 can_load(file_path, load_options) 

Parameters:

ParameterTypeDescription
file_pathstring
load_optionsLoadOptions

Returns

TypeDescription
bool

Method: can_load(stream) [static]

 can_load(stream) 

Parameters:

ParameterTypeDescription
stream_io.BufferedRandom

Returns

TypeDescription
bool

Method: can_load(stream, load_options) [static]

 can_load(stream, load_options) 

Parameters:

ParameterTypeDescription
stream_io.BufferedRandom
load_optionsLoadOptions

Returns

TypeDescription
bool

Method: can_save(options)

 can_save(options) 

Parameters:

ParameterTypeDescription
optionsImageOptionsBase

Returns

TypeDescription
bool

Method: convert_to_linked(linked_path)

 convert_to_linked(linked_path) 

Converts this embedded smart object to a linked smart object.

Parameters:

ParameterTypeDescription
linked_pathstringThe linked path.

Method: create(image_options, width, height) [static]

 create(image_options, width, height) 

Parameters:

ParameterTypeDescription
image_optionsImageOptionsBase
widthint
heightint

Returns

TypeDescription
Image

Method: duplicate_layer()

 duplicate_layer() 

Creates a new smart object layer by coping this one.
Notice that for embedded smart objects the embedded image is shared.
If you want to copy the embedded image use SmartObjectLayer.new_smart_object_via_copy() method.

Returns

TypeDescription
SmartObjectLayerThe cloned SmartObjectLayer instance.

Method: export_contents(file_path)

 export_contents(file_path) 

Exports the embedded or linked contents to a file.

Parameters:

ParameterTypeDescription
file_pathstringThe export file path.

Method: get_argb_32_pixel(x, y)

 get_argb_32_pixel(x, y) 

Parameters:

ParameterTypeDescription
xint
yint

Returns

TypeDescription
int

Method: get_default_argb_32_pixels(rectangle)

 get_default_argb_32_pixels(rectangle) 

Parameters:

ParameterTypeDescription
rectangleRectangle

Returns

TypeDescription
int

Method: get_default_options(args)

 get_default_options(args) 

Parameters:

ParameterTypeDescription
argsobject

Returns

TypeDescription
ImageOptionsBase

Method: get_default_raw_data(rectangle, raw_data_settings)

 get_default_raw_data(rectangle, raw_data_settings) 

Parameters:

ParameterTypeDescription
rectangleRectangle
raw_data_settingsRawDataSettings

Returns

TypeDescription
byte

Method: get_file_format(file_path) [static]

 get_file_format(file_path) 

Parameters:

ParameterTypeDescription
file_pathstring

Returns

TypeDescription
FileFormat

Method: get_file_format(stream) [static]

 get_file_format(stream) 

Parameters:

ParameterTypeDescription
stream_io.BufferedRandom

Returns

TypeDescription
FileFormat

Method: get_fitting_rectangle(rectangle, pixels, width, height) [static]

 get_fitting_rectangle(rectangle, pixels, width, height) 

Parameters:

ParameterTypeDescription
rectangleRectangle
pixelsint
widthint
heightint

Returns

TypeDescription
Rectangle

Method: get_fitting_rectangle(rectangle, width, height) [static]

 get_fitting_rectangle(rectangle, width, height) 

Parameters:

ParameterTypeDescription
rectangleRectangle
widthint
heightint

Returns

TypeDescription
Rectangle

Method: get_modify_date(use_default)

 get_modify_date(use_default) 

Parameters:

ParameterTypeDescription
use_defaultbool

Returns

TypeDescription
datetime

Method: get_original_options()

 get_original_options() 

Returns

TypeDescription
ImageOptionsBase

Method: get_pixel(x, y)

 get_pixel(x, y) 

Parameters:

ParameterTypeDescription
xint
yint

Returns

TypeDescription
Color

Method: get_proportional_height(width, height, new_width) [static]

 get_proportional_height(width, height, new_width) 

Parameters:

ParameterTypeDescription
widthint
heightint
new_widthint

Returns

TypeDescription
int

Method: get_proportional_width(width, height, new_height) [static]

 get_proportional_width(width, height, new_height) 

Parameters:

ParameterTypeDescription
widthint
heightint
new_heightint

Returns

TypeDescription
int

Method: get_skew_angle()

 get_skew_angle() 

Returns

TypeDescription
float

Method: load(file_path) [static]

 load(file_path) 

Parameters:

ParameterTypeDescription
file_pathstring

Returns

TypeDescription
Image

Method: load(file_path, load_options) [static]

 load(file_path, load_options) 

Parameters:

ParameterTypeDescription
file_pathstring
load_optionsLoadOptions

Returns

TypeDescription
Image

Method: load(stream) [static]

 load(stream) 

Parameters:

ParameterTypeDescription
stream_io.BufferedRandom

Returns

TypeDescription
Image

Method: load(stream, load_options) [static]

 load(stream, load_options) 

Parameters:

ParameterTypeDescription
stream_io.BufferedRandom
load_optionsLoadOptions

Returns

TypeDescription
Image

Method: load_argb_32_pixels(rectangle)

 load_argb_32_pixels(rectangle) 

Parameters:

ParameterTypeDescription
rectangleRectangle

Returns

TypeDescription
int

Method: load_argb_64_pixels(rectangle)

 load_argb_64_pixels(rectangle) 

Parameters:

ParameterTypeDescription
rectangleRectangle

Returns

TypeDescription
long

Method: load_cmyk_32_pixels(rectangle)

 load_cmyk_32_pixels(rectangle) 

Parameters:

ParameterTypeDescription
rectangleRectangle

Returns

TypeDescription
int

Method: load_cmyk_pixels(rectangle)

 load_cmyk_pixels(rectangle) 

Parameters:

ParameterTypeDescription
rectangleRectangle

Returns

TypeDescription
CmykColor[]

Method: load_contents(options)

 load_contents(options) 

Gets the embedded or linked image contents of the smart object layer.

Parameters:

ParameterTypeDescription
optionsLoadOptionsThe options.

Returns

TypeDescription
ImageThe loaded Image smart object instance.

Method: load_partial_argb_32_pixels(rectangle, partial_pixel_loader)

 load_partial_argb_32_pixels(rectangle, partial_pixel_loader) 

Loads 32-bit ARGB pixels partially (by blocks).

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to load pixels from.
partial_pixel_loaderIPartialArgb32PixelLoaderThe partial pixel loader.

Method: load_pixels(rectangle)

 load_pixels(rectangle) 

Parameters:

ParameterTypeDescription
rectangleRectangle

Returns

TypeDescription
Color[]

Method: load_raw_data(rectangle, raw_data_settings, raw_data_loader)

 load_raw_data(rectangle, raw_data_settings, raw_data_loader) 

Loads raw data.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to load raw data from.
raw_data_settingsRawDataSettingsThe raw data settings to use for loaded data. Note if data is not in the format specified then data conversion will be performed.
raw_data_loaderIPartialRawDataLoaderThe raw data loader.

Method: new_smart_object_via_copy()

 new_smart_object_via_copy() 

Creates a new smart object layer by coping this one.
Reproduces Layer -> Smart Objects -> New Smart Object via Copy functionality of Adobe� Photoshop�.
Notice that it is enabled only for embedded smart objects because the embedded image is also copied.
If you want to share the embedded image use SmartObjectLayer.duplicate_layer() method.

Returns

TypeDescription
SmartObjectLayerThe cloned SmartObjectLayer instance.

Method: read_argb_32_scan_line(scan_line_index)

 read_argb_32_scan_line(scan_line_index) 

Parameters:

ParameterTypeDescription
scan_line_indexint

Returns

TypeDescription
int

Method: read_scan_line(scan_line_index)

 read_scan_line(scan_line_index) 

Parameters:

ParameterTypeDescription
scan_line_indexint

Returns

TypeDescription
Color[]
 relink_to_file(linked_path) 

Re-links the linked smart object to a new file.
There is no need to call UpdateModifiedContent method afterwards.

Parameters:

ParameterTypeDescription
linked_pathstringThe linked path.

Method: replace_contents(image)

 replace_contents(image) 

Replaces the smart object contents embedded in the smart object layer.

Parameters:

ParameterTypeDescription
imageImageThe image.

Method: replace_contents(image, resolution)

 replace_contents(image, resolution) 

Replaces the smart object contents embedded in the smart object layer.

Parameters:

ParameterTypeDescription
imageImageThe image.
resolutionResolutionSettingThe resolution settings. If null the image resolution will be used.

Method: replace_contents(linked_path)

 replace_contents(linked_path) 

Replaces the contents with a file.
There is no need to call UpdateModifiedContent method afterwards.

Parameters:

ParameterTypeDescription
linked_pathstringThe linked path.

Method: replace_contents(linked_path, resolution)

 replace_contents(linked_path, resolution) 

Replaces the contents with a file.
There is no need to call UpdateModifiedContent method afterwards.

Parameters:

ParameterTypeDescription
linked_pathstringThe linked path.
resolutionResolutionSettingThe resolution settings. If null the image resolution will be used.

Method: shallow_copy()

 shallow_copy() 

Returns

TypeDescription
Layer

Method: to_bitmap()

 to_bitmap() 

Returns

TypeDescription
aspose.pydrawing.Bitmap