Skip to content

Commit

Permalink
Clarify JPEG tests for default/invalid subsampling
Browse files Browse the repository at this point in the history
-1 is the default; 3 is invalid and should behave the same as the default.
  • Loading branch information
bgilbert committed Dec 4, 2023
1 parent 9ea6d9e commit c2b5686
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Tests/test_file_jpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ def getsampling(im):
return layer[0][1:3] + layer[1][1:3] + layer[2][1:3]

# experimental API
im = self.roundtrip(hopper(), subsampling=-1) # default
assert getsampling(im) == (2, 2, 1, 1, 1, 1)
for subsampling in (-1, 3): # (default, invalid)
im = self.roundtrip(hopper(), subsampling=subsampling)
assert getsampling(im) == (2, 2, 1, 1, 1, 1)
for subsampling in (0, "4:4:4"):
im = self.roundtrip(hopper(), subsampling=subsampling)
assert getsampling(im) == (1, 1, 1, 1, 1, 1)
Expand All @@ -446,11 +447,8 @@ def getsampling(im):
im = self.roundtrip(hopper(), subsampling=subsampling)
assert getsampling(im) == (2, 2, 1, 1, 1, 1)

im = self.roundtrip(hopper(), subsampling=3) # default (undefined)
assert getsampling(im) == (2, 2, 1, 1, 1, 1)

# RGB colorspace, no subsampling by default
im = self.roundtrip(hopper(), subsampling=3, keep_rgb=True)
im = self.roundtrip(hopper(), keep_rgb=True)
assert getsampling(im) == (1, 1, 1, 1, 1, 1)

with pytest.raises(TypeError):
Expand Down

0 comments on commit c2b5686

Please sign in to comment.