Skip to content

Commit

Permalink
Can't test jpg like this
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanklut committed Dec 11, 2023
1 parent 89d5645 commit ebe368e
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions tests/test_image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,16 @@ def test_save_grayscale_jpg(self):
save_image_array_to_path(image_path, image)
self.assertTrue(image_path.is_file())

def test_save_load_color_jpg(self):
image = np.random.randint(0, 255, size=(64, 64, 3), dtype=np.uint8)
image_path = self.tmp_dir.joinpath(f"{uuid.uuid4()}.jpg")
save_image_array_to_path(image_path, image)
image2 = load_image_array_from_path(image_path, mode="color")
self.assertIsNotNone(image2)
self.assertTrue(np.array_equal(image, image2, equal_nan=True))

def test_save_load_grayscale_jpg(self):
image = np.random.randint(0, 255, size=(64, 64), dtype=np.uint8)
image_path = self.tmp_dir.joinpath(f"{uuid.uuid4()}.jpg")
save_image_array_to_path(image_path, image)
image2 = load_image_array_from_path(image_path, mode="grayscale")
self.assertIsNotNone(image2)
self.assertTrue(np.array_equal(image, image2, equal_nan=True))

def test_save_color_png(self):
image = np.random.randint(0, 255, size=(64, 64, 3), dtype=np.uint8)
image = np.zeros((64, 64, 3), dtype=np.uint8)
image[:16, :16, 0] = 255
image_path = self.tmp_dir.joinpath(f"{uuid.uuid4()}.png")
save_image_array_to_path(image_path, image)
self.assertTrue(image_path.is_file())

def test_save_grayscale_png(self):
image = np.random.randint(0, 255, size=(64, 64), dtype=np.uint8)
image = np.zeros((64, 64), dtype=np.uint8)
image[:16, :16] = 255
image_path = self.tmp_dir.joinpath(f"{uuid.uuid4()}.png")
save_image_array_to_path(image_path, image)
self.assertTrue(image_path.is_file())
Expand Down

0 comments on commit ebe368e

Please sign in to comment.