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

def CMFPhoto::Photo::Photo::_resize (   self,
  size,
  quality = DEFAULT_QUALITY 
) [private]

Resize and resample photo.

Definition at line 412 of file Photo.py.

00412                                                     :
        """Resize and resample photo."""
        image = StringIO()

        width = size[0]
        height = size[1]
        if len(size) == 3 and quality == DEFAULT_QUALITY:
            quality = size[2] 

        
        # check if picture needs to be rotated
        mirror, rotation = self.exif_orientation()
        if isPilAvailable:
            img = PIL.Image.open(StringIO(str(self.data)))
            fmt = img.format
            # Resize photo
            img.thumbnail((width, height), RESIZING_ALGO)
            if rotation:
                rotation = 360 - rotation
                img = img.rotate(rotation, ROTATING_ALGO)
            # Store copy in image buffer
            img.save(image, fmt, quality=quality)
        elif isConvertAvailable:
            geometry = "%sx%s" % (width, height)
            image = self.callConvert(image, rotate=rotation, geometry=geometry)
        else:
            if DEBUG:
                raise RuntimeError('Error in _resize: No image manipulation engine found! Pleas read the readme')

        return image

    security.declareProtected(CMFCorePermissions.View, 'getEXIF')
    def getEXIF(self):


Generated by  Doxygen 1.6.0   Back to index