On Feb 18, 2008, at 12:10 AM, Malcolm Tredinnick wrote:
>>
> How are you doing your image saving? In the normal course of things,
> the
> image data is saved to disk *before* the corresponding object is saved
> to the database. So that would mean it wasn't visible before saving
> was
> complete.
>
> However, maybe you're doing something funky. Do you have a (short)
> code
> sample that shows how you're doing the image saving?
>
> Malcolm
Here's the whole thing, it's not that long. I wish I knew if it was
funky or not... "stream" is a boolean saying whether I want an extra-
large version of the pic to be saved in a special directory,
everything else is bog-standard.
def save(self):
if not self.id:
from PIL import Image, ImageOps
img = Image.open(self.get_picFile_filename())
size = (120,90)
extrasize = (600,450)
info = img._getexif()
if info[0x0112] == 8:
img = img.rotate(90)
size = (90,120)
extrasize = (450,600)
if self.stream:
fileName = self.picFile.split('/')[-1]
extra = img.copy()
extra = ImageOps.fit(extra,extrasize, Image.ANTIALIAS,
0,(0.5,0.5))
extra.save(MEDIA_ROOT+"img/pics/big/"+fileName)
img = ImageOps.fit(img,size,Image.ANTIALIAS,0,(0.5,0.5))
img.save(self.get_picFile_filename())
super(Pic, self).save()
Many thanks,
Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---