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

def CMFPhoto::Photo::Photo::doTransform (   self,
  method,
  REQUEST = None 
)

Transform an Image:
    FLIP_LEFT_RIGHT
    FLIP_TOP_BOTTOM
    ROTATE_90 (rotate counterclockwise)
    ROTATE_180
    ROTATE_270 (rotate clockwise)

Definition at line 326 of file Photo.py.

00326                                                :
        """
        Transform an Image:
            FLIP_LEFT_RIGHT
            FLIP_TOP_BOTTOM
            ROTATE_90 (rotate counterclockwise)
            ROTATE_180
            ROTATE_270 (rotate clockwise)
        """ 
        image = StringIO()

        method = int(method)
        if isPilAvailable:
            img = PIL.Image.open(StringIO(str(self.data)))
            fmt = img.format
            img = img.transpose(method)
            img.save(image, fmt, quality=DEFAULT_QUALITY)
        elif isConvertAvailable: # fall back to convert
            if method in [ROTATE_90, ROTATE_180, ROTATE_270]:
                deg = 90
                if method == ROTATE_180:
                    deg = 180
                elif method == ROTATE_270:
                    deg = 270
                image = self.callConvert(image, rotate=deg)
                
            elif method == FLIP_LEFT_RIGHT:
                image = self.callConvert(image, 'flop')
            elif method == FLIP_TOP_BOTTOM:
                image = self.callConvert(image, 'flip')
            else:
                raise ValueError, "Unknown method '%s'" % (method,)
        else:
            if DEBUG:
                raise Exception('Error in doTransform')

        self.update_data(image.getvalue())

        if REQUEST:
             REQUEST.RESPONSE.redirect(self.absolute_url() + '/photo_transform')

    security.declarePrivate('callConvert')
    def callConvert(self, img_file_obj, *args, **kwargs):


Generated by  Doxygen 1.6.0   Back to index