コード例 #1
0
ファイル: test_giraffe.py プロジェクト: pu1kit0/giraffe
 def test_resize_only(self):
     pipeline = giraffe.build_pipeline({"w": 100, "h": 50})
     self.assertEqual(
         pipeline,
         [giraffe.ImageOp('resize', {
             'width': 100,
             'height': 50
         })])
コード例 #2
0
ファイル: test_giraffe.py プロジェクト: pu1kit0/giraffe
 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))
コード例 #3
0
ファイル: test_giraffe.py プロジェクト: pu1kit0/giraffe
 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))
コード例 #4
0
ファイル: test_giraffe.py プロジェクト: pu1kit0/giraffe
    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)
コード例 #5
0
ファイル: test_giraffe.py プロジェクト: pu1kit0/giraffe
    def test_rotate(self):
        pipeline = giraffe.build_pipeline({"rot": 90})

        self.assertEqual(pipeline,
                         [giraffe.ImageOp('rotate', {'degrees': 90})])
コード例 #6
0
ファイル: test_giraffe.py プロジェクト: pu1kit0/giraffe
 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))