views:

233

answers:

2

I'm putting together a Web site that makes heavy use of images. Those images need to be thumbnailed at various sizes to fit different templates.

I'm aware of solutions like sorl-thumbnail, which seems perfect in every way except one: I need to be able to override automatic resizing and cropping if the computer's choice is a bad one.

For instance: Say I upload a 1,000-by-1,000 pixel image. I need a 300-by-200 thumbnail of that image. The sorl-thumbnail solution, if I understand it right, is to rescale the image to 300-by-300 and then lop off the top and the bottom.

What I want to be able to do is a) accept the sorl-style solution if it works for the image, but b) be able to override the sorl choice -- in the admin, probably -- if that would work better. If it's a picture of a person, for example, maybe I would rather crop out the person's torso and just make a thumbnail out of her face, which happens to be located in the upper right corner?

There's no off-the-shelf pluggable solution for this, so far as I can tell (but please correct me if I'm wrong). Barring that, I'd like to hear your ideas about ways that the problem might be approached. Is there some sort of jQuery plugin that will get me halfway there?

Help!

+1  A: 

If you want to use an off-the-shelf pluggable there is django-photologue django-imagehandler. It allows you to generate thumbnails and do "manual-cropping" on the admin.

Another off-the-shelf solution is django-thumbs. django-thumbs overwrittes your imagefields. The only drawback is that you need to set up the sizes it will generate the thumbnails.

None of these 2 applications can fully solve your problem. But atleast you know where to start :)

django-photologue can generate thumbnails and add effects and watermarks.

EDIT: if you want to use jQuery to crop your images then you can take a look at jCrop. It's pretty easy to use. The main problem is that you will need to upload the image to your server and then crop it manually.

EDIT 2:Wrong information. It was not django-photologue but django-imagehandler.

ikkebr
Thanks for the answer! Photologue allows you to do "manual cropping," though? I can't find that in the docs. Got a citation?
hanksims
my bad. it was imagehandler and not photologue :(
ikkebr
Baresi beat you to imagehandler by a few minutes! But thanks so much for your informative answer.
hanksims
+1  A: 

sorl-thumbnail has smart cropping which will cut off the parts of the image with the least entropy. All you need to do is add crop="smart". It works really really well in most situations.

Otherwise you could check out django-imagehandler

Baresi
Imagehandler: just about perfect. The only thing it doesn't do for me, so far as I can tell, is define multiple thumbnails for each image -- a 150x150 one, a 300X200 one, etc. But it's 90 percent of the way to solving my problem. Thanks!
hanksims