htomika
htomika

Reputation: 41

How can I crop to square with Django Easy Thumbnails?

I'm using easy-thumbnails all over my site. It works fine generally. But now I'd want to create a product feed for Facebook and the pictures need to be 600x600px square.

It looks like this:

thumbnailer = get_thumbnailer(v.product.image)
thumbnail_options = {
  'crop': '50,0', #tried smart, scale and all kinds of combos
  'size': (600, 600)
}
resized_image = thumbnailer.get_thumbnail(thumbnail_options)

The problem is that I always end up getting one dimension to 600px, and the other to <600px. Can I make it do something like the smart option but cropping in a way that I get a square image?

Thank you in advance!

Upvotes: 1

Views: 1188

Answers (1)

Lauri Elias
Lauri Elias

Reputation: 1299

thumbnailer = get_thumbnailer(v.product.image)
thumbnail_options = {
  'crop': 'smart',
  'upscale': True,
  'size': (600, 600)
}
resized_image = thumbnailer.get_thumbnail(thumbnail_options)

Upvotes: 1

Related Questions