I may be able to offer some assistance here :)

i used the follow bit to create a thumbnail image and changed the name
of the file to include _tn.

def save(self):
        super(ImageUpload, self).save()
        if self.image:
           tsize = 150,150
           path = settings.MEDIA_ROOT + self.image.name
           img2 = Image.open(path)
           img2.thumbnail(tsize, Image.ANTIALIAS)
           img2.save(self.get_thumbnail_path())

    def get_thumbnail_path(self):
        path = settings.MEDIA_ROOT + self.image.name
        return self.convert_path_to_thumbnail(path)

    def convert_path_to_thumbnail(self, path):
        basedir = os.path.dirname(path) + '/'
        base, ext = os.path.splitext(os.path.basename(path))
        th_name = base + "_tn"
        th_name += ext
        return urlparse.urljoin(basedir,th_name)


On Jan 5, 8:41 pm, geirr <eriks...@gmail.com> wrote:
> Hello!
>
> I'm trying to make a simple photo album application.
>
> I can't figure out how to change the name of photos that are uploaded
> to something different than the name they have locally on my computer.
> I want to give the files new names, before they are saved. I am using
> the
> ImageField model field for the images.
>
> It looks like I have to override the save function? If this is
> correct, how do
> I do so? Which variable decides the name of the file? Can anyone point
> me in the right direction?
>
> Thanks,
>
> -geir
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to