mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-04 21:50:54 +03:00
Merge branch 'master' into 16-bit-rgb-tiff
This commit is contained in:
commit
21d1c4cef5
|
@ -4,6 +4,12 @@ Changelog (Pillow)
|
||||||
4.3.0 (unreleased)
|
4.3.0 (unreleased)
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
- Basic support for Termux (android) in setup.py #2684
|
||||||
|
[wiredfool]
|
||||||
|
|
||||||
|
- Bug: Fix Image.fromarray for numpy.bool type. #2683
|
||||||
|
[wiredfool]
|
||||||
|
|
||||||
- CI: Add Fedora 24 and 26 to Docker tests
|
- CI: Add Fedora 24 and 26 to Docker tests
|
||||||
[wiredfool]
|
[wiredfool]
|
||||||
|
|
||||||
|
@ -31,6 +37,9 @@ Changelog (Pillow)
|
||||||
- Remove unused im.copy2 and core.copy methods #2657
|
- Remove unused im.copy2 and core.copy methods #2657
|
||||||
[homm]
|
[homm]
|
||||||
|
|
||||||
|
- Fast Image.merge() #2677
|
||||||
|
[homm]
|
||||||
|
|
||||||
- Fast Image.split() #2676
|
- Fast Image.split() #2676
|
||||||
[homm]
|
[homm]
|
||||||
|
|
||||||
|
|
|
@ -2423,7 +2423,7 @@ def fromqpixmap(im):
|
||||||
_fromarray_typemap = {
|
_fromarray_typemap = {
|
||||||
# (shape, typestr) => mode, rawmode
|
# (shape, typestr) => mode, rawmode
|
||||||
# first two members of shape are set to one
|
# first two members of shape are set to one
|
||||||
# ((1, 1), "|b1"): ("1", "1"), # broken
|
((1, 1), "|b1"): ("1", "1;8"),
|
||||||
((1, 1), "|u1"): ("L", "L"),
|
((1, 1), "|u1"): ("L", "L"),
|
||||||
((1, 1), "|i1"): ("I", "I;8"),
|
((1, 1), "|i1"): ("I", "I;8"),
|
||||||
((1, 1), "<u2"): ("I", "I;16"),
|
((1, 1), "<u2"): ("I", "I;16"),
|
||||||
|
|
|
@ -39,7 +39,7 @@ class TestNumpy(PillowTestCase):
|
||||||
def to_image(dtype, bands=1, boolean=0):
|
def to_image(dtype, bands=1, boolean=0):
|
||||||
if bands == 1:
|
if bands == 1:
|
||||||
if boolean:
|
if boolean:
|
||||||
data = [0, 1] * 50
|
data = [0, 255] * 50
|
||||||
else:
|
else:
|
||||||
data = list(range(100))
|
data = list(range(100))
|
||||||
a = numpy.array(data, dtype=dtype)
|
a = numpy.array(data, dtype=dtype)
|
||||||
|
@ -58,9 +58,9 @@ class TestNumpy(PillowTestCase):
|
||||||
return i
|
return i
|
||||||
|
|
||||||
# Check supported 1-bit integer formats
|
# Check supported 1-bit integer formats
|
||||||
self.assertRaises(TypeError, lambda: to_image(numpy.bool))
|
self.assert_image(to_image(numpy.bool, 1, 1), '1', TEST_IMAGE_SIZE)
|
||||||
self.assertRaises(TypeError, lambda: to_image(numpy.bool8))
|
self.assert_image(to_image(numpy.bool8, 1, 1), '1', TEST_IMAGE_SIZE)
|
||||||
|
|
||||||
# Check supported 8-bit integer formats
|
# Check supported 8-bit integer formats
|
||||||
self.assert_image(to_image(numpy.uint8), "L", TEST_IMAGE_SIZE)
|
self.assert_image(to_image(numpy.uint8), "L", TEST_IMAGE_SIZE)
|
||||||
self.assert_image(to_image(numpy.uint8, 3), "RGB", TEST_IMAGE_SIZE)
|
self.assert_image(to_image(numpy.uint8, 3), "RGB", TEST_IMAGE_SIZE)
|
||||||
|
@ -213,5 +213,13 @@ class TestNumpy(PillowTestCase):
|
||||||
self.assertEqual(im.size, (0, 0))
|
self.assertEqual(im.size, (0, 0))
|
||||||
|
|
||||||
|
|
||||||
|
def test_bool(self):
|
||||||
|
# https://github.com/python-pillow/Pillow/issues/2044
|
||||||
|
a = numpy.zeros((10,2), dtype=numpy.bool)
|
||||||
|
a[0][0] = True
|
||||||
|
|
||||||
|
im2 = Image.fromarray(a)
|
||||||
|
self.assertEqual(im2.getdata()[0], 255)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
5
depends/termux.sh
Executable file
5
depends/termux.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
pkg -y install python python-dev ndk-sysroot clang make \
|
||||||
|
libjpeg-turbo-dev
|
||||||
|
|
|
@ -185,6 +185,19 @@ unpack1IR(UINT8* out, const UINT8* in, int pixels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
unpack18(UINT8* out, const UINT8* in, int pixels)
|
||||||
|
{
|
||||||
|
/* Unpack a '|b1' image, which is a numpy boolean.
|
||||||
|
1 == true, 0==false, in bytes */
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < pixels; i++) {
|
||||||
|
out[i] = in[i] > 0 ? 255 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Unpack to "L" image */
|
/* Unpack to "L" image */
|
||||||
|
|
||||||
|
@ -1244,6 +1257,7 @@ static struct {
|
||||||
{"1", "1;I", 1, unpack1I},
|
{"1", "1;I", 1, unpack1I},
|
||||||
{"1", "1;R", 1, unpack1R},
|
{"1", "1;R", 1, unpack1R},
|
||||||
{"1", "1;IR", 1, unpack1IR},
|
{"1", "1;IR", 1, unpack1IR},
|
||||||
|
{"1", "1;8", 1, unpack18},
|
||||||
|
|
||||||
/* greyscale */
|
/* greyscale */
|
||||||
{"L", "L;2", 2, unpackL2},
|
{"L", "L;2", 2, unpackL2},
|
||||||
|
|
8
setup.py
8
setup.py
|
@ -365,6 +365,14 @@ class pil_build_ext(build_ext):
|
||||||
# work ;-)
|
# work ;-)
|
||||||
self.add_multiarch_paths()
|
self.add_multiarch_paths()
|
||||||
|
|
||||||
|
# termux support for android.
|
||||||
|
# system libraries (zlib) are installed in /system/lib
|
||||||
|
# headers are at $PREFIX/include
|
||||||
|
# user libs are at $PREFIX/lib
|
||||||
|
if os.environ.get('ANDROID_ROOT', None):
|
||||||
|
_add_directory(library_dirs,
|
||||||
|
os.path.join(os.environ['ANDROID_ROOT'],'lib'))
|
||||||
|
|
||||||
elif sys.platform.startswith("gnu"):
|
elif sys.platform.startswith("gnu"):
|
||||||
self.add_multiarch_paths()
|
self.add_multiarch_paths()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user