<<add to top of file>>

import os, Image
TINY_SIZE = (80,80)    #thumb size (x,y)

<<add to Model>>

	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 """<a href="/media/%s"><img src="/media/%s" alt="tiny thumbnail image" /></a>"""%(self.image,tinythumb)
	thumb.allow_tags = True