Permalink
Browse files

Retina display mode

  • Loading branch information...
1 parent 7ef1c2e commit f778c0fc719c21717715eaabe1014b4dec9c94df @Rydgel committed Nov 26, 2012
Showing with 17 additions and 0 deletions.
  1. +4 −0 README.md
  2. +5 −0 app.py
  3. +8 −0 tests.py
View
@@ -19,6 +19,10 @@ Use them directly in an image tag or a CSS background, or whatever you want to.
There are three *bonus* fonts you can choose by passing `font=lobster`, `font=bebas`, or `font=museo` in the URL.
+## Retina mode
+
+Just pass the `retina=1` in the URL. Your image will be 2 times bigger.
+
## Set up your own instance
Prerequisites:
View
5 app.py
@@ -51,6 +51,11 @@ def placeholder(width, height=None, bgd="cccccc", fgd="909090"):
# grab the font, default is yanone
# fakeimg.pl/400x400/?font=lobster
font = request.args.get('font', 'yanone')
+ # retina mode, just make the image twice bigger
+ retina = request.args.get('retina', None)
+ if retina:
+ width = 2 * width
+ height = 2 * height
# processing image
im = pil_image(width, height, bgd, fgd, txt, font)
return serve_pil_image(im)
View
@@ -108,6 +108,14 @@ def testPlaceholder4(self):
r = self.app.get('/200x100/eeeeeee/fff')
self.assertEquals(r.status_code, 404)
+ def testRetina(self):
+ r = self.app.get('/200x100/eee/000/?retina=1')
+ self.assertEquals(r.status_code, 200)
+ self.assertEquals(r.mimetype, 'image/png')
+ img = self._open_image(r.data)
+ width, height = img.size
+ self.assertEquals(width, 400)
+ self.assertEquals(height, 200)
if __name__ == '__main__':
unittest.main()

0 comments on commit f778c0f

Please sign in to comment.