psd_tools.api.smart_object
Smart object module.
SmartObject
- class psd_tools.api.smart_object.SmartObject(layer)[source]
Smart object that represents embedded or external file.
Smart objects are attached to
SmartObjectLayer
.- property data: bytes
Embedded file content, or empty if kind is external or alias
- property filename: str
Original file name of the object.
- property filesize: int
File size of the object.
- property filetype: str
Preferred file extension, such as jpg.
- property kind: str
Kind of the link, ‘data’, ‘alias’, or ‘external’.
- open(external_dir: str | None = None) Iterator[BytesIO] [source]
Open the smart object as binary IO.
- Parameters:
external_dir – Path to the directory of the external file.
Example:
with layer.smart_object.open() as f: data = f.read()
- property resolution
Resolution of the object.
- save(filename: str | None = None) None [source]
Save the smart object to a file.
- Parameters:
filename – File name to export. If None, use the embedded name.
- property transform_box
A tuple representing the coordinates of the smart objects’s transformed box. This box is the result of one or more transformations such as scaling, rotation, translation, or skewing to the original bounding box of the smart object.
The format of the tuple is as follows: (x1, y1, x2, y2, x3, y3, x4, y4)
Where 1 is top left corner, 2 is top right, 3 is bottom right and 4 is bottom left.
- property unique_id: str
UUID of the object.
- property warp
Warp parameters.