예제 #1
0
파일: layers.py 프로젝트: thkien/psd-tools2
 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)
예제 #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()
예제 #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()