fields.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:django-croppie 作者: dima-kov 项目源码 文件源码
def crop_image(self, data_image, ratio):
        image = Image.open(data_image)
        cropped_image = image.crop(ratio)

        # saving image to memory
        thumb_io = io.BytesIO()
        cropped_image.save(
            thumb_io,
            data_image.content_type.split('/')[-1].upper()
        )

        # creating new InMemoryUploadedFile() based on the modified file
        file = InMemoryUploadedFile(
            thumb_io,
            'photo',
            data_image._get_name(),
            data_image.content_type,
            None, None,
        )
        return file
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号