English 中文(简体)
User-Defined Thumnails for Django Project?
原标题:

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!

最佳回答

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

问题回答

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.





相关问题
How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

Moving (very old) Zope/Plone Site to Django

I am ask to move data from a (now offline) site driven by Plone to a new Django site. These are the version informations I have: Zope Version (unreleased version, python 2.1.3 ) Python Version 2.1....

Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

Flexible pagination in Django

I d like to implement pagination such that I can allow the user to choose the number of records per page such as 10, 25, 50 etc. How should I go about this? Is there an app I can add onto my project ...

is it convenient to urlencode all next parameters? - django

While writing code, it is pretty common to request a page with an appended "next" query string argument. For instance, in the following template code next points back to the page the user is on: &...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

热门标签