def test_images_in_expr(self): img1_path = "hopper.ppm" img2_path = "pal1wb.bmp" with PIL.open(path_to_file_in_data_dir(img1_path)) as img1: with PIL.open(path_to_file_in_data_dir(img2_path)) as img2: res = self.kernel_session.evaluate( wl.Map(wl.ImageDimensions, {"img1": img1, "img2": img2}) ) self.assertEqual( res, { "img1": self.IMAGE_FILES_DIMS[img1_path], "img2": self.IMAGE_FILES_DIMS[img2_path], }, )
def test_png_mode_I(self): with PIL.open(path_to_file_in_data_dir('5x2.png')) as image: self.assertEqual( export(image, target_format='wl'), b'ImportByteArray[ByteArray["iVBORw0KGgoAAAANSUhEUgAAAAUAAAACEAAAAADlkZXCAAAAH0lEQVR4nGP0+P39rf6+ky9/R7Aoen2+9shDWSRCHwCO7ws73c3PRQAAAABJRU5ErkJggg=="], "PNG"]' )
def test_images_serialization(self): for path, dimensions in self.IMAGE_FILES_DIMS.items(): with PIL.open(path_to_file_in_data_dir(path)) as img: res = self.kernel_session.evaluate(wl.ImageDimensions(img)) self.assertEqual(res, dimensions)