开发者

Resizing image on upload with django-imagekit

开发者 https://www.devze.com 2022-12-30 05:51 出处:网络
I am using imagekit to handle custom size of uploaded images开发者_Go百科. While it works fine for creating custom size images with this, I\'d like to use imagekit to resize the original image on uplo

I am using imagekit to handle custom size of uploaded images开发者_Go百科. While it works fine for creating custom size images with this, I'd like to use imagekit to resize the original image on upload. Is this possible?


follow the link above.

  • Create processors as you like for original image (resize, enhance, etc). Look imagekit wiki for examples

    class ResizeOriginal(processors.Resize): 
        width = 640 
        height = 480
    
  • Create your ImageSpec for this original image with those previously processors. Leave pre_cache as default (false)

    class Original(ImageSpec): 
        processors = [ResizeOriginal] 
    
  • Add that ImageSpec to your IKoptions ImageModel preprocessor.

    preprocessor_spec = Original


I believe the updated answer is ProcessedImageField.

Reference taken from @matthew.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号