Hi -
I'm building a site for a client that needs to support image uploads (an artist) through the admin interface. Since most of the images are pretty high-res, I wanted to create thumb copies of the image to display on the gallery page after the upload. The upload works great with the forms.ImageFile element, but I was looking for some ideas on how to do the actual resizing and and linking between the thumb and the true size images. I had an idea to hold model class for both an image and an image thumb:
from django.db import models
class Image(models.Model):
"""a true size image"""
image = models.ImageFile(upload_to="images")
desc = models.CharField(max_length=256)
class Meta:
db_table = "images"
class ImageThumb(models.Model):
""""a thumbnail of an actual image"""
real_image = models.ForeignKey('Image')
image = models.ImageField(upload_to="images/thumbs")
class Meta:
db_table = "thumbs"
That part I'm stuck on is how to resize the real image after upload (pil? how?), and I could probably use some polishing on my models - any help will be great. Thanks.