Example #1
0
 def test_fit_liquid(self):
     pipeline = [giraffe.ImageOp('liquid', {'width': 100, 'height': 100})]
     try:
         img = giraffe.process_image(self.image, pipeline)
     except MissingDelegateError:
         pytest.skip(
             "ImageMagick doesn't have Liquid Rescale support compiled in")
     self.assertEqual(img.size, (100, 100))
Example #2
0
 def test_fit_liquid(self):
     pipeline = [giraffe.ImageOp('liquid', {
                     'width': 100,
                     'height': 100,
                     }),
                 ]
     img = giraffe.process_image(self.image, pipeline)
     self.assertEqual(img.size, (100, 100))
Example #3
0
 def test_fit_crop_center(self):
     pipeline = [giraffe.ImageOp(giraffe.fit_crop, {
                     'width': 100,
                     'height': 100,
                     'anchor': 'center',
                     }),
                 ]
     img = giraffe.process_image(self.image, pipeline)
     self.assertEqual(img.size, (100, 100))
Example #4
0
 def test_fit_crop_center(self):
     pipeline = [
         giraffe.ImageOp(giraffe.fit_crop, {
             'width': 100,
             'height': 100,
             'anchor': 'center'
         })
     ]
     img = giraffe.process_image(self.image, pipeline)
     self.assertEqual(img.size, (100, 100))
Example #5
0
    def test_rotate(self):
        # draw an image with a single red column in the middle
        with Color('white') as bg, Color('red') as fg:
            image = Image(width=100, height=100, background=bg)
            with Drawing() as draw:
                draw.fill_color = fg
                draw.stroke_color = fg
                draw.rectangle(left=50, top=0, right=54, bottom=image.height)
                draw(image)

        pipeline = [giraffe.ImageOp('rotate', {'degrees':90})]
        rotated_image = giraffe.process_image(image, pipeline)

        # verify that that image has a sideways bar of red in the middle
        for i, row in enumerate(rotated_image):
            for col in row:
                self.assertEqual(col.red, 1.0)

                if 50 <= i <= 54:
                    self.assertEqual(col.blue, 0.0)
                    self.assertEqual(col.green, 0.0)
                else:
                    self.assertNotEqual(col.blue, 0.0)
                    self.assertNotEqual(col.green, 0.0)
Example #6
0
    def test_rotate(self):
        # draw an image with a single red column in the middle
        with Color('white') as bg, Color('red') as fg:
            image = Image(width=100, height=100, background=bg)
            with Drawing() as draw:
                draw.fill_color = fg
                draw.stroke_color = fg
                draw.rectangle(left=50, top=0, right=54, bottom=image.height)
                draw(image)

        pipeline = [giraffe.ImageOp('rotate', {'degrees': 90})]
        rotated_image = giraffe.process_image(image, pipeline)

        # verify that that image has a sideways bar of red in the middle
        for i, row in enumerate(rotated_image):
            for col in row:
                self.assertEqual(col.red, 1.0)

                if 50 <= i <= 54:
                    self.assertEqual(col.blue, 0.0)
                    self.assertEqual(col.green, 0.0)
                else:
                    self.assertNotEqual(col.blue, 0.0)
                    self.assertNotEqual(col.green, 0.0)
Example #7
0
 def test_resize(self):
     pipeline = [
         giraffe.ImageOp("resize", {'width':100, 'height': 100}),
     ]
     img = giraffe.process_image(self.image, pipeline)
     self.assertEqual(img.size, (100, 100))
Example #8
0
 def test_resize(self):
     pipeline = [giraffe.ImageOp("resize", {'width': 100, 'height': 100})]
     img = giraffe.process_image(self.image, pipeline)
     self.assertEqual(img.size, (100, 100))