django-imagekit icon indicating copy to clipboard operation
django-imagekit copied to clipboard

Possible to prevent auto-rotation/flip?

Open bsolomon1124 opened this issue 3 years ago • 3 comments

An ImageSpecField with a ResizeToFit processor will be auto-rotated 90 degrees if the ResizeToFit dimension "ratio" contradicts the original uploaded image height/width ratio.

Is it possible to prevent this auto-rotation?

class Image(models.Model):
    is_primary = models.BooleanField(
        blank=True,
        default=False,
    )
    image = models.ImageField(upload_to="uploads/")
    thumbnail = ImageSpecField(
        source="image", processors=[ResizeToFit(550, 400)], format="JPEG", options={"quality": 60}
    )

    caption = models.CharField(blank=True, max_length=128)

If I uploaded an image 3024 pixels width x 4032 pixels height, this image has a height larger than width, so will be flipped, since the ResizeToFit uses a slightly larger width than height.

(Let me know if this would be better asked in https://github.com/matthewwithanm/pilkit.)

bsolomon1124 avatar Jan 30 '21 16:01 bsolomon1124

Hello,

I'm looking at the code at pilkit/processors/resize.py and can't see a logic for explicitly rotating an image. I'm not sure if it is coming from Pillow somehow if in the metadata of the image there is information about the orientation of the image (if it was taken from phone for example).

vstoykov avatar Feb 13 '21 23:02 vstoykov

@bsolomon1124 Have you found some sort of workaround? I'm also experiencing this.

MilyMilo avatar Sep 04 '21 10:09 MilyMilo

Hi! I experienced the same issue, adding Transpose(), before all processors helped me

https://github.com/matthewwithanm/django-imagekit/issues/238#issuecomment-21569897

allburov avatar Nov 27 '21 11:11 allburov

Based on the comment by @allburov I think that the current issue is duplicate of #238 and I'll close the issue.

vstoykov avatar Apr 05 '23 21:04 vstoykov