Skip to content

Instantly share code, notes, and snippets.

View fabeat's full-sized avatar
🎯
Focusing

Fabian Graßl fabeat

🎯
Focusing
  • cadooz GmbH
  • Nürnberg
View GitHub Profile
@enagorny
enagorny / scale.py
Created June 21, 2012 15:24
PIL scale with whitespace adding
def scale(image, max_size, method=Image.ANTIALIAS):
"""
resize 'image' to 'max_size' keeping the aspect ratio
and place it in center of white 'max_size' image
"""
im_aspect = float(image.size[0])/float(image.size[1])
out_aspect = float(max_size[0])/float(max_size[1])
if im_aspect >= out_aspect:
scaled = image.resize((max_size[0], int((float(max_size[0])/im_aspect) + 0.5)), method)
else:
@fabeat
fabeat / README
Created May 4, 2010 11:02
MYSQL SLUG FIX (Unique fix)
MYSQL SLUG FIX
The table 'content' contains pages with a slug. This slug should be unique but it isn't.
unique_fix.sql fixes this problem and makes the slug-column unique.