def rsize(cls, oldPaste, weight, height): assert oldPaste.is_image img = cropresize2.crop_resize(Image.open(oldPaste.path), (int(weight), int(height))) return cls.create_by_img(img, oldPaste.filename, oldPaste.mimetype)
def rsize(cls, old_paste, weight, height): assert old_paste.is_image img = cropresize2.crop_resize( Image.open(old_paste.path), (int(weight), int(height))) return cls.create_by_img(img, old_paste.filename, old_paste.mimetype)
def rsize(cls, old_paste, weight, height): assert old_paste.is_image, TypeError('Unsuppoprted Image Type') img = cropresize2.crop_resize(Image.open(old_paste.path), (int(weight), int(height))) rst = cls(old_paste.filename, old_paste.mimetype, 0) img.save(rst.path) filestat = os.stat(rst.path) rst.size = filestat.st_size return rst
def rsize(self, width, height): if (width, height) == self.size: return self with open(self.filepath, 'rb') as f: img = Image.open(f) result = cropresize2.crop_resize(img, (width, height), exact_size=False) result.save(self.filepath) return self
def rsize(cls, old_paste, weight, height): assert old_paste.is_image, TypeError('Unsupported Image Type.') img = cropresize2.crop_resize( Image.open(old_paste.path), (int(weight), int(height))) rst = cls(old_paste.filename, old_paste.mimetype, 0) img.save(rst.path) filestat = os.stat(rst.path) rst.size = filestat.st_size return rst
def create_file_after_crop(cls, uploadedFile, width, height): assert uploadedFile.is_image, TypeError("Unsupported Image Type.") img = cropresize2.crop_resize(Image.open(uploadedFile), (int(width), int(height))) rst = cls(uploadedFile.filename, uploadedFile.mimetype, 0) img.save(rst.path) filestat = os.stat(rst.path) rst.size = filestat.st_size return rst
def create_file_after_crop(cls, uploaded_file, width, height): assert uploaded_file.is_image, TypeError('Unsupported Image Type.') img = cropresize2.crop_resize( Image.open(uploaded_file), (int(width), int(height))) rst = cls(uploaded_file.filename, uploaded_file.mimetype, 0) img.save(rst.path) filestat = os.stat(rst.path) rst.size = filestat.st_size return rst
def resize(cls, old_file, width, height): """ Resize the image and return a new image (the old one is kept) """ assert old_file.is_image, TypeError('Unsupported Image Type.') img = cropresize2.crop_resize( Image.open(old_file.path), (int(width), int(height)) ) r = cls(old_file.filename, old_file.mimetype) img.save(r.path) filestat = os.stat(r.path) r.size = filestat.st_size # commit db session in the outside view return r
def _resize(self, im, size, upscale, crop_mode): return crop_resize(im, size, exact_size=upscale, crop_mode=crop_mode)
def rsize(file_path, weight, height): img = cropresize2.crop_resize( Image.open(file_path), (int(weight), int(height))) return img