mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 17:54:32 +03:00
CHECK: support for int arrays as ifd entries
This commit is contained in:
parent
1d6f6ffa10
commit
49191c78fb
|
@ -1036,8 +1036,8 @@ def _save(im, fp, filename):
|
|||
continue
|
||||
if type(v) == tuple and len(v) > 2:
|
||||
# List of ints?
|
||||
# BitsPerSample is one example, I get (8,8,8)
|
||||
# UNDONE
|
||||
if type(v[0]) in (int, float):
|
||||
atts[k] = list(v)
|
||||
continue
|
||||
if type(v) == tuple and len(v) == 2:
|
||||
# one rational tuple
|
||||
|
|
35
encode.c
35
encode.c
|
@ -780,18 +780,35 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args)
|
|||
} else if(PyList_Check(value)) {
|
||||
int len,i;
|
||||
float *floatav;
|
||||
int *intav;
|
||||
TRACE(("Setting from List: %d \n", (int)PyInt_AsLong(key)));
|
||||
len = (int)PyList_Size(value);
|
||||
TRACE((" %d elements, setting as floats \n", len));
|
||||
floatav = malloc(sizeof(float)*len);
|
||||
if (floatav) {
|
||||
for (i=0;i<len;i++) {
|
||||
floatav[i] = (float)PyFloat_AsDouble(PyList_GetItem(value,i));
|
||||
if (len) {
|
||||
if (PyInt_Check(PyList_GetItem(value,0))) {
|
||||
TRACE((" %d elements, setting as ints \n", len));
|
||||
intav = malloc(sizeof(int)*len);
|
||||
if (intav) {
|
||||
for (i=0;i<len;i++) {
|
||||
intav[i] = (int)PyInt_AsLong(PyList_GetItem(value,i));
|
||||
}
|
||||
status = ImagingLibTiffSetField(&encoder->state,
|
||||
(ttag_t) PyInt_AsLong(key),
|
||||
intav);
|
||||
free(intav);
|
||||
}
|
||||
} else {
|
||||
TRACE((" %d elements, setting as floats \n", len));
|
||||
floatav = malloc(sizeof(float)*len);
|
||||
if (floatav) {
|
||||
for (i=0;i<len;i++) {
|
||||
floatav[i] = (float)PyFloat_AsDouble(PyList_GetItem(value,i));
|
||||
}
|
||||
status = ImagingLibTiffSetField(&encoder->state,
|
||||
(ttag_t) PyInt_AsLong(key),
|
||||
floatav);
|
||||
free(floatav);
|
||||
}
|
||||
}
|
||||
status = ImagingLibTiffSetField(&encoder->state,
|
||||
(ttag_t) PyInt_AsLong(key),
|
||||
floatav);
|
||||
free(floatav);
|
||||
}
|
||||
} else if (PyFloat_Check(value)) {
|
||||
TRACE(("Setting from Float: %d, %f \n", (int)PyInt_AsLong(key),PyFloat_AsDouble(value)));
|
||||
|
|
Loading…
Reference in New Issue
Block a user