photoshop.protocol
- class photoshop.protocol.ContentType(*values)
Message content type.
- CANCEL_COMMAND = 8
- DATA = 5
- ERROR_STRING = 1
- EVENT_STATUS = 9
- FILE_STREAM = 7
- ILLEGAL = 0
- IMAGE = 3
- KEEP_ALIVE = 6
- PROFILE = 4
- SCRIPT = 2
- SCRIPT_SHARED = 10
- class photoshop.protocol.Pixmap(width: int, height: int, row_bytes: int, color_mode: int, channels: int, bits: int, data: bytes)
Pixmap representing an uncompressed pixels, ARGB, row-major order.
- Variables:
width – width of the image.
height – height of the image.
row_bytes – bytes per row.
color_mode – color mode of the image.
channels – number of channels.
bits – bits per pixel.
data – raw data bytes.
- dump() bytes
Dump Pixmap to bytes.
- topil() Image
Convert to PIL Image.
- class photoshop.protocol.Protocol(password: str)
Photoshop protocol.
- VERSION = 1
- receive(socket: socket) Dict[str, Any]
Receives data from Photoshop.
- Parameters:
socket – socket to receive data.
- Returns:
dict of the following fields.
status: execution status, 0 when success, otherwise error.
protocol: protocol version, equal to 1.
transaction: transaction id.
content_type: data type. See
ContentType.body: body of the response data, dict for IMAGE type, otherwise bytes.
Example:
{ 'status': 0, 'protocol': 1, 'transaction': 0, 'content_type': ContentType.SCRIPT, 'body': b'[ActionDescriptor]' }
- Raises:
AssertionError – if response format is invalid.
- send(socket: socket, content_type: ContentType, data: bytes, transaction: int = 0, status: int = 0) None
Sends data to Photoshop.
- Parameters:
content_type – See
ContentType.data – bytes to send.
transaction – transaction id.
status – execution status, should be 0.