def image_manual_crop(self, src_path, dest_path=None): # sizes: (left, top, right, bottom) if isinstance(self._image_params['crop'], tuple) != (0, 0, 0, 0): image = Image(src_path=src_path) image.crop_manual_with_offsets(offsets=self._image_params['crop'], dest_path=dest_path) image.close()
def test_convert(self): file = files_paths[0][0] image = Image(root_path + file) basename = file[0:file.find('.')] basename = root_path + '/temp' + basename + '.bmp' image.convert(basename) image.close() self.assertTrue(path.isfile(basename))
def test_gray1(self): file = files_paths[1] fs.unlink(root_path + file[1]) image = Image(root_path + file[0]) image.gray(root_path + file[1]) image.close() image = PilImage.open(root_path + file[1]) index = image.mode.find('L') image.close() self.assertTrue(index == 0)
def test_auto_crop3(self): file = files_paths[4] fs.unlink(root_path + file[1]) image = PilImage.open(root_path + file[0]) sizes = image.size image.close() img = Image(root_path + file[0]) img.crop_auto(root_path + file[1]) img.close() cropped_image = PilImage.open(root_path + file[1]) cropped_sizes = cropped_image.size cropped_image.close() self.assertTrue(sizes[0] == (2 + cropped_sizes[0])) # 2px black line
def test_manual_crop_with_offsets(self): for file in files_paths: fs.unlink(root_path + file[1]) image = PilImage.open(root_path + file[0]) sizes = image.size image.close() img = Image(root_path + file[0]) img.crop_manual_with_offsets((10, 0, 0, 0), root_path + file[1]) img.close() cropped_image = PilImage.open(root_path + file[1]) cropped_sizes = cropped_image.size cropped_image.close() self.assertTrue((sizes[0] - cropped_sizes[0]) == 10)
def test_image_not_found(self): self.assertRaises(AttributeError, lambda: Image(root_path))
def image_auto_crop(src_path, dest_path=None): image = Image(src_path=src_path) image.crop_auto(dest_path=dest_path) image.close()