def topil(self): """ Get PIL Image of the layer. :return: :py:class:`PIL.Image`, or `None` if the layer has no pixels. """ if self.has_pixels(): return convert_layer_to_pil(self) return None
def topil(self, channel=None, **kwargs): """ Get PIL Image of the layer. :param channel: Which channel to return; e.g., 0 for 'R' channel in RGB image. See :py:class:`~psd_tools.constants.ChannelID`. When `None`, the method returns all the channels supported by PIL modes. :return: :py:class:`PIL.Image`, or `None` if the layer has no pixels. Example:: from psd_tools.constants import ChannelID image = layer.topil() red = layer.topil(ChannelID.CHANNEL_0) alpha = layer.topil(ChannelID.TRANSPARENCY_MASK) .. note:: Not all of the PSD image modes are supported in :py:class:`PIL.Image`. For example, 'CMYK' mode cannot include alpha channel in PIL. In this case, topil drops alpha channel. """ return convert_layer_to_pil(self, channel, **kwargs)