Exemplo n.º 1
0
 def test_thumbnail_size(self):
     img_name, r = self.upload()
     # get the thumbnail link
     self.img_id = test_utils.get_img_id(img_name)
     r = self.client.get('/embed/thumbnail/%s' % (self.img_id))
     self.assertEquals(r.status_code, 301)
     imgio = test_utils.download_image(r.location)
     img = Image.open(imgio)
     self.assertEquals('%sx%s' % img.size, app.config.get('THUMBNAIL_SIZE'))
Exemplo n.º 2
0
    def test_resize_single_dimension(self):
        img_name, r = self.upload()
        img_w, img_h = self.get_image_size()

        self.img_id = test_utils.get_img_id(img_name)
        r = self.client.get('/embed/file/%s?size=100' % (self.img_id))
        self.assertEquals(r.status_code, 301)
        resized_img = test_utils.download_image(r.location)
        resized_w, resized_h = self.get_image_size(resized_img)
        self.assertEquals(resized_w, 100)
        # check aspect ratio
        self.assertEquals(int(img_w/resized_w), int(img_h/resized_h))