Layer#
Similar to the C++ bindings this is the base class for all layer types, unlike C++ there is no reason to actually use this type as casting down the inheritance chain is done implicitly. We can however use this to indicate a return type for type hinting.
def some_function() -> psapi.Layer_8bit:
'''
Return a layer type
'''
pass
This is why we dont actually specify any constructors for the Layer class. If you try and construct a layer object you will get an error
layer = psapi.Layer_8bit() # -> TypeError: psapi.Layer_8bit: No constructor defined!
Similarly the Layer<>::Params class from C++ is not implemented here but rather the arguments are implemented as kwargs for the individual constructors
Class Reference Layer#
- class psapi.Layer_8bit#
Base type that all layers inherit from, this class should not be instantiated and instead the derivatives such as
psapi.GroupLayer_8bitorpsapi.ImageLayer_8bitshould be used (with the appropriate bit depth).- Attributes:
- namestr
The name of the layer, cannot be longer than 255
- masknp.ndarray
The pixel mask applied to the layer
- blend_modeenum.BlendMode
The blend mode of the layer, ‘Passthrough’ is reserved for group layers
- opacityint
The layers opacity from 0-255 with 255 being 100%
- widthint
The width of the layer ranging up to 30,000 for PSD and 300,000 for PSB, this does not have to match the files width
- heightint
The height of the layer ranging up to 30,000 for PSD and 300,000 for PSB, this does not have to match the files height
- center_xfloat
The center of the layer in regards to the canvas, a layer at center_x = 0 is perfectly centered around the document
- center_yfloat
The center of the layer in regards to the canvas, a layer at center_y = 0 is perfectly centered around the document
- is_locked: bool
The locked state of the layer, this locks all pixel channels
- is_visible: bool
Whether the layer is visible
- has_mask(self: psapi.Layer_8bit) bool#
Check whether the layer has a mask channel associated with it.