jdriscoll/django-imagekit — Issue #51: pre_cache delayed job
Author: hzy-
Created: 2011-11-05 14:17:00+00:00
State: open

Hey, I have my Photo model as you can see below, and I would like to have the 4 different image sizes created when a new photo is uploaded, or there abouts. I was wondering if there's been any attempt to use something like celery to have a background queue for generating images?

thanks.

````python
class Photo(models.Model):
user = models.ForeignKey(User)
title = models.CharField(max_length = 100, blank=True)
description = models.TextField(blank=True)
is_active = models.BooleanField(default=False)
original_image = models.ImageField(upload_to = imagefield_upload_to)

thumbnail = ImageSpec(
processors = [
resize.Crop(width=100, height=100),
Adjust(sharpness=1.2),
],
image_field = 'original_image',
format = 'JPEG',
quality = 85,
pre_cache = True,
cache_to = 'photos/t',
)

large_image = ImageSpec(
processors = [
resize.Fit(width=1024, height=1024),
Adjust(sharpness=1.2),
],
image_field = 'original_image',
format = 'JPEG',
quality = 85,
pre_cache = True,
cache_to = 'photos/l',
)

medium_image = ImageSpec(
processors = [
resize.Fit(width=640, height=640),
Adjust(sharpness=1.2),
],
image_field = 'original_image',
format = 'JPEG',
quality = 85,
pre_cache = True,
cache_to = 'photos/m',
)

small_image = ImageSpec(
processors = [
resize.Fit(width=240, height=240),
Adjust(sharpness=1.2),
],
image_field = 'original_image',
format = 'JPEG',
quality = 85,
pre_cache = True,
cache_to = 'photos/s',
)

def __unicode__(self):
return u'%s by %s' % (self.title, self.user.username)
````