4. Modules: Image Helpers
4.1. PIL Image Helper
- StreamDeck.ImageHelpers.PILHelper.create_image(deck, background='black')
Creates a new PIL Image with the correct image dimensions for the given StreamDeck device’s keys.
See also
See
to_native_format()
method for converting a PIL image instance to the native image format of a given StreamDeck device.- Parameters
deck (StreamDeck) – StreamDeck device to generate a compatible image for.
background (str) – Background color to use, compatible with PIL.Image.new().
- Return type
PIL.Image
- Returns
Created PIL image
- StreamDeck.ImageHelpers.PILHelper.create_scaled_image(deck, image, margins=[0, 0, 0, 0], background='black')
Creates a new key image that contains a scaled version of a given image, resized to best fit the given StreamDeck device’s keys with the given margins around each side.
The scaled image is centered within the new key image, offset by the given margins. The aspect ratio of the image is preserved.
See also
See
to_native_format()
method for converting a PIL image instance to the native image format of a given StreamDeck device.- Parameters
deck (StreamDeck) – StreamDeck device to generate a compatible image for.
image (Image) – PIL Image object to scale
list(int) – Array of margin pixels in (top, right, bottom, left) order.
background (str) – Background color to use, compatible with PIL.Image.new().
- Rtrype
PIL.Image
- Returns
Loaded PIL image scaled and centered
- StreamDeck.ImageHelpers.PILHelper.to_native_format(deck, image)
Converts a given PIL image to the native image format for a StreamDeck, suitable for passing to
set_key_image()
.See also
See
create_image()
method for creating a PIL image instance for a given StreamDeck device.- Parameters
deck (StreamDeck) – StreamDeck device to generate a compatible native image for.
image (PIL.Image) – PIL Image to convert to the native StreamDeck image format
- Return type
enumerable()
- Returns
Image converted to the given StreamDeck’s native format