def test_resize_only(self): pipeline = giraffe.build_pipeline({"w": 100, "h": 50}) self.assertEqual( pipeline, [giraffe.ImageOp('resize', { 'width': 100, 'height': 50 })])
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))
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))
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)
def test_rotate(self): pipeline = giraffe.build_pipeline({"rot": 90}) self.assertEqual(pipeline, [giraffe.ImageOp('rotate', {'degrees': 90})])
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))