-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
Description
Moving to a more standard install of MapProxy, using Pillow. Pillow can load 16 bit grayscale TIFF images, but can't create them. Similar bug was in PIL. Steps to reproduce:
# python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image;
>>> filename = "GMTED.tiff";
>>> img = Image.open(filename);
>>> img.mode
'I;16S'
>>> img.size
(256, 256)
>>> img1 = Image.core.new(img.mode, img.size);
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: unrecognized mode
>>> In the old PIL code, the changes below would fix the problem. I will need to look at the Pillow code to see if it is similar enough to make the same mods.
Imaging.h - increase buffer for mode to avoid overrun in Storage.c
char mode[6+1]; /* Band names ("1", "L", "P", "RGB", "RGBA", "CMYK", "YCbCr", "BGR;xy") */
Access.c - add I;16S to list and update hash code to avoid collision with new value
#define ACCESS_TABLE_SIZE 25
#define ACCESS_TABLE_HASH 5543
ADD("I;16S", line_16, get_pixel_16L, put_pixel_16L);
Pack.c - add I;16S to storage modes using "copy2"
{"I;16S", "I;16S", 16, copy2},
Storage.c - change multiple strcmp(mode, ...) to single strncmp(mode, "I;16", 4) so all cases are covered
} if (strncmp(mode, "I;16", 4) == 0) {
Unpack.c - add I;16S to the "storage modes" part of the unpackers array
{"I;16S", "I;16S", 16, copy2},
Convert.c - Add converter references
{ "I", "I;16S", I_I16L },
{ "I;16S", "I", I16L_I },
{ "L", "I;16S", L_I16L },
{ "I;16S", "L", I16L_L },
ImageMode.py - Add I;16S to mapping modes
_modes["I;16S"] = ModeDescriptor("I;16S", "I", "L", "L")