<> import os, Image TINY_SIZE = (80,80) #thumb size (x,y) <> def thumb(self): tinythumb = self.image.replace('\\','/').split('/') tinythumb[-1] = 'tiny/'+tinythumb[-1] tinythumb = '/'.join(tinythumb) if not os.path.exists(MEDIA_ROOT+tinythumb): im = Image.open(MEDIA_ROOT+self.image) im.thumbnail(TINY_SIZE,Image.ANTIALIAS) im.save(MEDIA_ROOT+tinythumb,"JPEG") return """tiny thumbnail image"""%(self.image,tinythumb) thumb.allow_tags = True