def create_image(self, name, dim, transparent=False):
filename = os.path.join(settings.MEDIA_ROOT, name)<EOL>im = Image.new('<STR_LIT:L>', dim)<EOL>if transparent:<EOL><INDENT>draw = ImageDraw.Draw(im)<EOL>draw.line((<NUM_LIT:0>, <NUM_LIT:0>) + im.size, fill=<NUM_LIT>)<EOL>draw.line((<NUM_LIT:0>, im.size[<NUM_LIT:1>], im.size[<NUM_LIT:0>], <NUM_LIT:0>), fill=<NUM_LIT>)<EOL>im.save(filename, transparency=<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>im.save(filename)<EOL><DEDENT>return Item.objects.get_or_create(image=name)<EOL>
Creates an image and prepends the MEDIA ROOT path.
:param name: e.g. 500x500.jpg
:param dim: a dimension tuple e.g. (500, 500)