Logo Search packages:      
Sourcecode: zope-photo version File versions  Download package

def zope-photo-1.2.4::Photo::Photo::_resize (   self,
  display,
  width,
  height,
  engine = 'PIL',
  quality = 75 
) [private]

Resize and resample photo.

Definition at line 347 of file Photo.py.

00347                                                                        :
        """Resize and resample photo."""
        origimg = self._original
        newimg = StringIO()
        if engine == 'PIL':  # Use PIL
            img = PIL.Image.open(origimg._PILdata())
            fmt = img.format
            try:
                img = img.resize((width, height), PIL.Image.ANTIALIAS)
            except AttributeError:
                img = img.resize((width, height))
            img.save(newimg, fmt, quality=quality)
        elif engine == 'ImageMagick':  # Use ImageMagick
            if sys.platform == 'win32':
                from win32pipe import popen2
                imgin, imgout = popen2('convert -quality %s -geometry %sx%s - -'
                                       % (quality, width, height), 'b')
            else:
                from popen2 import popen2
                imgout, imgin = popen2('convert -quality %s -geometry %sx%s - -'
                                       % (quality, width, height))
            imgin.write(origimg._IMdata())
            imgin.close()
            newimg.write(imgout.read())
            imgout.close()

        newimg.seek(0)
        return newimg

    def _getDisplayData(self, display):


Generated by  Doxygen 1.6.0   Back to index