Chris Hoeppner <[EMAIL PROTECTED]> writes: > Maybe something like > > def save(self): > self.imageField = pil.thumbnail(self.imageField) > > Can't really tell if I'm on the right track here.
Search the list... I've got this from the list: IMAGE_SIZE = [300, 300] THUMBNAIL_SIZE = [100, 100] UPLOAD_TO="photos/%Y/%M%d" THUMBS_TO="thumbs/%Y/%M%d" class Mugshot(models.Model): """Represents a single picture of the user""" person = models.ForeignKey(Person) shot = models.ImageField(upload_to=UPLOAD_TO) thumb = models.ImageField(upload_to=THUMBS_TO, editable=False) name = models.CharField(maxlength=500, blank=True) def __str__(self): return self.name def get_url(self): try: m = re.match(settings.MEDIA_ROOT + "(.*)", self.get_shot_filename()) return n.group(1) except: return self.get_shot_filename() # Django thumbs hack from super jared. # http://superjared.com/entry/django-quick-tips-2-image-thumbnails/ def save(self): logger = logging.getLogger("Mugshot.save") from PIL import Image if not self.thumb: self.save_thumb_file(self.get_shot_filename(), '') image = Image.open(self.get_shot_filename()) # Convert to RGB if necessary # Thanks to Limodou on DjangoSnippets.org # http://www.djangosnippets.org/snippets/20/ if image.mode not in ('L', 'RGB'): image = image.convert('RGB') cropped = utils.image_crop(image, IMAGE_SIZE) cropped.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS) cropped.save(self.get_thumb_filename()) # Save this photo instance super(Mugshot, self).save() # Now resize the main image image = Image.open(self.get_shot_filename()) if image.mode not in ('L', 'RGB'): image = image.convert('RGB') cropped = utils.image_crop(image, IMAGE_SIZE) cropped.thumbnail(IMAGE_SIZE, Image.ANTIALIAS) cropped.save(self.get_shot_filename()) class Admin: pass -- Nic Ferrier http://www.tapsellferrier.co.uk --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---