Skip to content

Commit 0054c7d

Browse files
committed
add some more gifload tests
1 parent b2cfe6a commit 0054c7d

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

test/test-suite/test_foreign.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -811,25 +811,33 @@ def gif_valid(im):
811811
self.file_loader("gifload", GIF_FILE, gif_valid)
812812
self.buffer_loader("gifload_buffer", GIF_FILE, gif_valid)
813813

814-
# 'n' param added in 8.5
815-
if pyvips.at_least_libvips(8, 5):
816-
x1 = pyvips.Image.new_from_file(GIF_ANIM_FILE)
817-
x2 = pyvips.Image.new_from_file(GIF_ANIM_FILE, n=2)
818-
assert x2.height == 2 * x1.height
819-
page_height = x2.get("page-height")
820-
assert page_height == x1.height
814+
# test metadata
815+
x2 = pyvips.Image.new_from_file(GIF_ANIM_FILE, n=-1)
816+
# our test gif has delay 0 for the first frame set in error
817+
assert x2.get("delay") == [0, 50, 50, 50, 50]
818+
assert x2.get("loop") == 32760
819+
assert x2.get("background") == [255, 255, 255]
820+
# test deprecated fields too
821+
assert x2.get("gif-loop") == 32759
822+
assert x2.get("gif-delay") == 0
823+
824+
# test every pixel
825+
x1 = pyvips.Image.new_from_file(GIF_ANIM_FILE, n=-1)
826+
x2 = pyvips.Image.new_from_file(GIF_ANIM_EXPECTED_PNG_FILE)
827+
assert (x1 - x2).abs().max() == 0
821828

822-
x2 = pyvips.Image.new_from_file(GIF_ANIM_FILE, n=-1)
823-
assert x2.height == 5 * x1.height
824-
# our test gif has delay 0 for the first frame set in error
825-
assert x2.get("delay") == [0, 50, 50, 50, 50]
829+
# test page handling
830+
x1 = pyvips.Image.new_from_file(GIF_ANIM_FILE)
831+
x2 = pyvips.Image.new_from_file(GIF_ANIM_FILE, n=2)
832+
assert x2.height == 2 * x1.height
833+
page_height = x2.get("page-height")
834+
assert page_height == x1.height
826835

827-
x2 = pyvips.Image.new_from_file(GIF_ANIM_FILE, page=1, n=-1)
828-
assert x2.height == 4 * x1.height
836+
x2 = pyvips.Image.new_from_file(GIF_ANIM_FILE, n=-1)
837+
assert x2.height == 5 * x1.height
829838

830-
x1 = pyvips.Image.new_from_file(GIF_ANIM_FILE, n=-1)
831-
x2 = pyvips.Image.new_from_file(GIF_ANIM_EXPECTED_PNG_FILE)
832-
assert (x1 - x2).abs().max() == 0
839+
x2 = pyvips.Image.new_from_file(GIF_ANIM_FILE, page=1, n=-1)
840+
assert x2.height == 4 * x1.height
833841

834842
@skip_if_no("gifload")
835843
def test_gifload_animation_dispose_background(self):

0 commit comments

Comments
 (0)