示例#1
0
 def storeScale(self, instance, scale, **data):
     """ store a scaled version of the image """
     image = ImageScale(**data)
     field = self.context
     field.getStorage(instance).set(image.getId(),
                                    instance,
                                    image,
                                    mimetype=image.content_type,
                                    filename=image.filename)
示例#2
0
 def make(self, info):
     """ instantiate an object implementing `IImageScale` """
     mimetype = info['mimetype']
     info['content_type'] = mimetype
     info['filename'] = self.context.getFilename()
     scale = ImageScale(info['uid'], **info)
     scale.size = len(scale.data)
     url = self.context.absolute_url()
     extension = mimetype.split('/')[-1]
     scale.url = '%s/@@images/%s.%s' % (url, info['uid'], extension)
     return scale