Skip to content

Instantly share code, notes, and snippets.

@StasKoval
Created July 21, 2014 11:52
Show Gist options
  • Save StasKoval/91fee7744ebde2996237 to your computer and use it in GitHub Desktop.
Save StasKoval/91fee7744ebde2996237 to your computer and use it in GitHub Desktop.
def process(self, image):
font1 = logoimg = os.path.join(settings.MEDIA_ROOT, "fonts/KOKILAB.TTF")
(x,y) = image.size
font = ImageFont.truetype(font1, x/6)
logoim = Image.new('RGBA', (x, y), (0,0,0,0)) # Create a blank image
draw = ImageDraw.Draw(logoim)
draw.text((0,0), 'DOROHOUSE', font=font,fill=(0, 0, 0, 75))
new = logoim.resize((x,y),Image.NEAREST)
if x>y:
image.paste(new, (int(x/12),int(y/2.7)), new)
return image
if y>x:
image.paste(new, (int(x/12),int(y/2.3)), new)
return image
if x==y:
image.paste(new, (int(x/12),int(x/2.4)), new)
return image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment