Exemplo n.º 1
0
 def as_PIL(self, vector=False):
     """Returns a PIL image for this layer."""
     if vector or (not self.has_box() and not self.has_relevant_pixels()):
         # TODO: Replace polygon with bezier curve.
         return pil_support.draw_polygon(self.bbox, self.get_anchors(),
                                         self._get_color())
     else:
         return self._psd._layer_as_PIL(self._index)
Exemplo n.º 2
0
 def as_PIL(self, draw=False):
     """Returns a PIL image for this layer."""
     if draw or not self.has_pixels():
         # TODO: Replace polygon with bezier curve.
         drawing = pil_support.draw_polygon(self._psd.viewbox,
                                            self._get_anchors(),
                                            self._get_color())
         return drawing.crop(self.bbox)
     else:
         return super(ShapeLayer, self).as_PIL()
Exemplo n.º 3
0
 def as_PIL(self, draw=False):
     """Returns a PIL image for this layer."""
     if draw or self._must_draw():
         # TODO: Replace polygon with bezier curve.
         mode = {
             ColorMode.RGB: 'RGBA',
             ColorMode.GRAYSCALE: 'LA',
             ColorMode.CMYK: 'CMYKA',
         }.get(self._psd.header.color_mode, 'RGBA')
         drawing = pil_support.draw_polygon(
             self._psd.viewbox,
             self._get_anchors(),
             mode=mode,
             fill=self._get_color(mode),
         )
         return drawing.crop(self.bbox)
     else:
         return super(ShapeLayer, self).as_PIL()