Django: resize image before upload

后端 未结 3 1991
我寻月下人不归
我寻月下人不归 2020-12-01 11:33

I want to resize image(Pillow) before upload, I write code below but doesn\'t work! and get error:

AttributeError at /m

3条回答
  •  爱一瞬间的悲伤
    2020-12-01 12:11

    For image resizing you can make use of djanof easy thumbnail library.

    Below is the sample code,that i have used in my project

    options = {'size': (200, 200), 'crop': True}
    thumb_url =get_thumbnailer(image path).get_thumbnail(options).url
    

    For reference https://github.com/SmileyChris/easy-thumbnails

提交回复
热议问题