diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index b0e7c9639..f9f208af4 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -1183,6 +1183,8 @@ def _save(im, fp, filename): atts = {} # bits per sample is a single short in the tiff directory, not a list. atts[BITSPERSAMPLE] = bits[0] + if EXTRASAMPLES in ifd: + atts[EXTRASAMPLES] = list(ifd[EXTRASAMPLES]) # Merge the ones that we have with (optional) more bits from # the original file, e.g x,y resolution so that we can # save(load('')) == original file. diff --git a/encode.c b/encode.c index 6bdb8c71a..0f66e230b 100644 --- a/encode.c +++ b/encode.c @@ -770,7 +770,7 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args) } status = ImagingLibTiffSetField(&encoder->state, (ttag_t) PyInt_AsLong(key), - intav); + len, intav); free(intav); } } else { @@ -782,7 +782,7 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args) } status = ImagingLibTiffSetField(&encoder->state, (ttag_t) PyInt_AsLong(key), - floatav); + len, floatav); free(floatav); } }