Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Placeholder centering
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Sinchok committed Apr 14, 2014
1 parent 78ca854 commit d103dbb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
14 changes: 7 additions & 7 deletions betty/cropper/utils/placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ def placeholder(ratio, width, extension):
ratio = Ratio(random.choice((settings.BETTY_RATIOS)))
height = int(round((width * ratio.height / float(ratio.width))))

img = Image.new("RGB", (width, height))
bg_fill = random.choice(settings.BETTY_PLACEHOLDER_COLORS)
img = Image.new("RGB", (width, height), bg_fill)

draw = ImageDraw.Draw(img)
bg_fill = random.choice(settings.BETTY_PLACEHOLDER_COLORS)
draw.rectangle((0, 0, width, height), fill=bg_fill)

print(settings.BETTY_PLACEHOLDER_FONT)
font = ImageFont.truetype(filename=settings.BETTY_PLACEHOLDER_FONT, size=45)
text_size = draw.textsize(ratio.string, font=font)
print(text_size)
text_coords = (
int(round((width / 2.0) - (text_size[0] / 2.0))),
int(round((height / 2.0) - (text_size[1] / 2.0))),
int(round((width - text_size[0]) / 2.0)),
int(round((height - text_size[1]) / 2) - 15),
)
draw.text(text_coords, ratio.string, font=font)
print(text_coords)
draw.text(text_coords, ratio.string, font=font, fill=(256, 256, 256))
if extension == 'jpg':
pillow_kwargs = {"format": "jpeg", "quality": 80}
if extension == 'png':
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Django>=1.4
logan==0.5.9.1
slimit==0.8.1
wand==0.3.5
Pillow==2.4.0
South==0.8.4
jsonfield==0.9.20
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
install_requires = [
"Django>=1.4",
"slimit==0.8.1",
"wand==0.3.5",
"Pillow==2.4.0",
"South==0.8.4",
"logan==0.5.9.1",
"jsonfield==0.9.20",
Expand Down

0 comments on commit d103dbb

Please sign in to comment.