@@ -117,10 +117,16 @@ def test_bigtiff(self, tmp_path: Path) -> None:
117117
118118 def test_bigtiff_save (self , tmp_path : Path ) -> None :
119119 outfile = str (tmp_path / "temp.tif" )
120- hopper ().save (outfile , big_tiff = True )
120+ im = hopper ()
121+ im .save (outfile , big_tiff = True )
121122
122- with Image .open (outfile ) as im :
123- assert im .tag_v2 ._bigtiff is True
123+ with Image .open (outfile ) as reloaded :
124+ assert reloaded .tag_v2 ._bigtiff is True
125+
126+ im .save (outfile , save_all = True , append_images = [im ], big_tiff = True )
127+
128+ with Image .open (outfile ) as reloaded :
129+ assert reloaded .tag_v2 ._bigtiff is True
124130
125131 def test_seek_too_large (self ) -> None :
126132 with pytest .raises (ValueError , match = "Unable to seek to frame" ):
@@ -740,7 +746,7 @@ def im_generator(ims: list[Image.Image]) -> Generator[Image.Image, None, None]:
740746 assert reread .n_frames == 3
741747
742748 def test_fixoffsets (self ) -> None :
743- b = BytesIO (b"II\x2a \x00 \x00 \x00 \x00 \x00 " )
749+ b = BytesIO (b"II\x2A \x00 \x00 \x00 \x00 \x00 " )
744750 with TiffImagePlugin .AppendingTiffWriter (b ) as a :
745751 b .seek (0 )
746752 a .fixOffsets (1 , isShort = True )
@@ -753,6 +759,37 @@ def test_fixoffsets(self) -> None:
753759 with pytest .raises (RuntimeError ):
754760 a .fixOffsets (1 )
755761
762+ b = BytesIO (b"II\x2A \x00 \x00 \x00 \x00 \x00 " )
763+ with TiffImagePlugin .AppendingTiffWriter (b ) as a :
764+ a .offsetOfNewPage = 2 ** 16
765+
766+ b .seek (0 )
767+ a .fixOffsets (1 , isShort = True )
768+
769+ b = BytesIO (b"II\x2B \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 " )
770+ with TiffImagePlugin .AppendingTiffWriter (b ) as a :
771+ a .offsetOfNewPage = 2 ** 32
772+
773+ b .seek (0 )
774+ a .fixOffsets (1 , isShort = True )
775+
776+ b .seek (0 )
777+ a .fixOffsets (1 , isLong = True )
778+
779+ def test_appending_tiff_writer_writelong (self ) -> None :
780+ data = b"II\x2A \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 "
781+ b = BytesIO (data )
782+ with TiffImagePlugin .AppendingTiffWriter (b ) as a :
783+ a .writeLong (2 ** 32 - 1 )
784+ assert b .getvalue () == data + b"\xff \xff \xff \xff "
785+
786+ def test_appending_tiff_writer_rewritelastshorttolong (self ) -> None :
787+ data = b"II\x2A \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 "
788+ b = BytesIO (data )
789+ with TiffImagePlugin .AppendingTiffWriter (b ) as a :
790+ a .rewriteLastShortToLong (2 ** 32 - 1 )
791+ assert b .getvalue () == data [:- 2 ] + b"\xff \xff \xff \xff "
792+
756793 def test_saving_icc_profile (self , tmp_path : Path ) -> None :
757794 # Tests saving TIFF with icc_profile set.
758795 # At the time of writing this will only work for non-compressed tiffs
0 commit comments