matthewwithanm / django-imagekit

Automated image processing for Django. Currently v4.0
http://django-imagekit.rtfd.org/
BSD 3-Clause "New" or "Revised" License
2.26k stars 276 forks source link

How to prevent auto cropping ? #485

Closed pyprism closed 5 years ago

pyprism commented 5 years ago

Currently this is my model:


class ProductImage(models.Model):
    image = models.ImageField(upload_to='shop/product')
    image_thumbnail_index = ImageSpecField(source='image',
                                           processors=[ResizeToFill(308, 412)],
                                           format='JPEG',
                                           options={'quality': 100})

If I use ResizeToFill, some images automatically cropped. Then I tried ResizeToFit but sometimes it is not respecting image height (412) . How to use django-imagekit without auto cropping and sacrificing width/height ?

zhuyuecai commented 5 years ago

Yes, I have the same issue. ResizeToFill will just crop the image, most of the time. ResizeToFit will cause image distortion if the h/w ratio is different from the original image.

vstoykov commented 5 years ago

Image resizing is a tricky thing especially if you have images with different ratio as input and you want as output images of the same size. Now before I try to answer your question I first want from you to provide us with more information.

  1. Original image that you want to resize;
  2. Manually created resized image with Photoshop or GIMP or some other software of your choice. This manually created image should represent the desired result which we need to deliver with ImageKit;
  3. Image created with ResizeToFill (with desired size as arguments);
  4. Image created with ResizeToFIt (with the same size arguments as above);
  5. Image created with ResizeToCover (with the same size arguments as above);

@pyprism can you do this?

vstoykov commented 5 years ago

@zhuyuecai why do you think that ResizeToFit is causing image distortion? Can you provide some examples of distorted images created with that processor?