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
|
continue
|
||||||
if type(v) == tuple and len(v) > 2:
|
if type(v) == tuple and len(v) > 2:
|
||||||
# List of ints?
|
# List of ints?
|
||||||
# BitsPerSample is one example, I get (8,8,8)
|
if type(v[0]) in (int, float):
|
||||||
# UNDONE
|
atts[k] = list(v)
|
||||||
continue
|
continue
|
||||||
if type(v) == tuple and len(v) == 2:
|
if type(v) == tuple and len(v) == 2:
|
||||||
# one rational tuple
|
# one rational tuple
|
||||||
|
|
35
encode.c
35
encode.c
|
@ -780,18 +780,35 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args)
|
||||||
} else if(PyList_Check(value)) {
|
} else if(PyList_Check(value)) {
|
||||||
int len,i;
|
int len,i;
|
||||||
float *floatav;
|
float *floatav;
|
||||||
|
int *intav;
|
||||||
TRACE(("Setting from List: %d \n", (int)PyInt_AsLong(key)));
|
TRACE(("Setting from List: %d \n", (int)PyInt_AsLong(key)));
|
||||||
len = (int)PyList_Size(value);
|
len = (int)PyList_Size(value);
|
||||||
TRACE((" %d elements, setting as floats \n", len));
|
if (len) {
|
||||||
floatav = malloc(sizeof(float)*len);
|
if (PyInt_Check(PyList_GetItem(value,0))) {
|
||||||
if (floatav) {
|
TRACE((" %d elements, setting as ints \n", len));
|
||||||
for (i=0;i<len;i++) {
|
intav = malloc(sizeof(int)*len);
|
||||||
floatav[i] = (float)PyFloat_AsDouble(PyList_GetItem(value,i));
|
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)) {
|
} else if (PyFloat_Check(value)) {
|
||||||
TRACE(("Setting from Float: %d, %f \n", (int)PyInt_AsLong(key),PyFloat_AsDouble(value)));
|
TRACE(("Setting from Float: %d, %f \n", (int)PyInt_AsLong(key),PyFloat_AsDouble(value)));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user