Skip to content

Commit

Permalink
Corrected passing TIFF_LONG to libtiff
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Apr 1, 2023
1 parent aa9ecac commit b1b0353
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,16 @@ def test_save_ycbcr(self, tmp_path):
assert reloaded.tag_v2[530] == (1, 1)
assert reloaded.tag_v2[532] == (0, 255, 128, 255, 128, 255)

def test_save_imagesourcedata(self, tmp_path):
def test_exif_ifd(self, tmp_path):
outfile = str(tmp_path / "temp.tif")
with Image.open("Tests/images/tiff_adobe_deflate.tif") as im:
assert im.tag_v2[34665] == 125456
im.save(outfile)

with Image.open(outfile) as reloaded:
if Image.core.libtiff_support_custom_tags:
assert reloaded.tag_v2[34665] == 125456

def test_crashing_metadata(self, tmp_path):
# issue 1597
with Image.open("Tests/images/rdf.tif") as im:
Expand Down
2 changes: 1 addition & 1 deletion src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
&encoder->state, (ttag_t)key_int, (UINT16)PyLong_AsLong(value));
} else if (type == TIFF_LONG) {
status = ImagingLibTiffSetField(
&encoder->state, (ttag_t)key_int, (UINT32)PyLong_AsLong(value));
&encoder->state, (ttag_t)key_int, PyLong_AsLongLong(value));
} else if (type == TIFF_SSHORT) {
status = ImagingLibTiffSetField(
&encoder->state, (ttag_t)key_int, (INT16)PyLong_AsLong(value));
Expand Down

0 comments on commit b1b0353

Please sign in to comment.