Resize image on upload with django-imagekit

I am using imagekit to handle custom size of uploaded images. While it's great for generating custom sized images with this, I would like to use imagekit to resize the original image on upload. Is it possible?

+2


a source to share


2 answers


follow the link above.



  • Create processors however you like for the original image (resizing, enhancing, etc.). Check out the imagekit wiki for examples

    class ResizeOriginal(processors.Resize): 
        width = 640 
        height = 480
    
          

  • Create your ImageSpec for this original image with those processors previously processed. Leave pre_cache at default (false)

    class Original(ImageSpec): 
        processors = [ResizeOriginal] 
    
          

  • Add this ImageSpec to your IQoptions ImageModel preprocessor.

    preprocessor_spec = Original

+1


a source


I believe the updated answer is ProcessedImageField .



Link taken from @matthew .

0


a source







All Articles