def test_read_image_resize_scalar(self): edge_size = 200 image = self.load_image(backend="PIL") aspect_ratio = utils.calculate_aspect_ratio( (image.height, image.width)) image_size = utils.edge_to_image_size(edge_size, aspect_ratio) actual = io.read_image(self.default_image_file(), size=edge_size) desired = image.resize(image_size[::-1]) self.assertImagesAlmostEqual(actual, desired)
def test_read_image_resize_other(self): with self.assertRaises(RuntimeError): io.read_image(self.default_image_file(), size="invalid_size")
def test_read_image_resize(self): image_size = (200, 300) actual = io.read_image(self.default_image_file(), size=image_size) desired = self.load_image(backend="PIL").resize(image_size[::-1]) self.assertImagesAlmostEqual(actual, desired)
def test_read_image(self): actual = io.read_image(self.default_image_file()) desired = self.load_image() self.assertTrue(utils.is_batched_image(actual)) self.assertImagesAlmostEqual(actual, desired)