@@ -671,7 +671,7 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args)
671671 // This list also exists in TiffTags.py
672672 const int core_tags [] = {
673673 256 , 257 , 258 , 259 , 262 , 263 , 266 , 269 , 274 , 277 , 278 , 280 , 281 , 340 ,
674- 341 , 282 , 283 , 284 , 286 , 287 , 296 , 297 , 321 , 338 , 32995 , 32998 , 32996 ,
674+ 341 , 282 , 283 , 284 , 286 , 287 , 296 , 297 , 320 , 321 , 338 , 32995 , 32998 , 32996 ,
675675 339 , 32997 , 330 , 531 , 530 , 65537
676676 };
677677
@@ -801,7 +801,26 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args)
801801 TRACE (("Setting from Tuple: %d \n" , key_int ));
802802 len = PyTuple_Size (value );
803803
804- if (type == TIFF_SHORT ) {
804+ if (key_int == TIFFTAG_COLORMAP ) {
805+ int stride = 256 ;
806+ if (len != 768 ) {
807+ PyErr_SetString (PyExc_ValueError , "Requiring 768 items for for Colormap" );
808+ return NULL ;
809+ }
810+ UINT16 * av ;
811+ /* malloc check ok, calloc checks for overflow */
812+ av = calloc (len , sizeof (UINT16 ));
813+ if (av ) {
814+ for (i = 0 ;i < len ;i ++ ) {
815+ av [i ] = (UINT16 )PyLong_AsLong (PyTuple_GetItem (value ,i ));
816+ }
817+ status = ImagingLibTiffSetField (& encoder -> state , (ttag_t ) key_int ,
818+ av ,
819+ av + stride ,
820+ av + stride * 2 );
821+ free (av );
822+ }
823+ } else if (type == TIFF_SHORT ) {
805824 UINT16 * av ;
806825 /* malloc check ok, calloc checks for overflow */
807826 av = calloc (len , sizeof (UINT16 ));
0 commit comments