diff --git a/CHANGES.rst b/CHANGES.rst index 80e12e0a2..5a3432b3f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,9 +1,33 @@ Changelog (Pillow) ================== -2.2.0 (2013-10-01) +2.2.1 (2013-10-02) ------------------ +- Fix #356: Error installing Pillow 2.2.0 on Mac OS X (due to hard dep on brew) + [wiredfool] + +2.2.0 (2013-10-02) +------------------ + +- Fix #254: Bug in image transformations resulting from uninitialized memory + [nikmolnar] + +- Fix for encoding of b_whitespace, similar to closed issue #272 + [mhogg] + +- Fix #273: Add numpy array interface support for 16 and 32 bit integer modes + [cgohlke] + +- Partial fix for #290: Add preliminary support for TIFF tags. + [wiredfool] + +- Fix #251 and #326: circumvent classification of pngtest_bad.png as malware + [cgohlke] + +- Add typedef uint64_t for MSVC. + [cgohlke] + - Fix #329: setup.py: better support for C_INCLUDE_PATH, LD_RUN_PATH, etc. [nu774] diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 493ef0682..778be7151 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -1,7 +1,7 @@ Contributors (Pillow) ===================== -.. Note:: New contributors: please add your name here and send a pull request +.. Note:: Contributors: please add your name here - Alex Po - Anton Vlasenko diff --git a/MANIFEST.in b/MANIFEST.in index 763e36a8d..bfad0f9ad 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,21 +1,52 @@ -exclude .hgignore -exclude .hgtags -exclude BUILDME.bat -exclude make-manifest.py -exclude SHIP -exclude SHIP.bat -include *.rst include *.c include *.h -include selftest.py tox.ini -include COPYING -recursive-include Tests *.py *.txt -graft Tests/fonts -graft Tests/icc -graft Tests/images -recursive-include Scripts *.py README -graft Images -recursive-include docs *.txt *.html *.rst *.css *.py README CHANGES CONTENTS Makefile make.bat BUILDME LICENSE COPYING -recursive-include libImaging *.c *.h -recursive-include Tk *.c *.txt -recursive-include Sane *.c *.txt CHANGES README *.py +include *.py +include *.rst +include .gitattributes +include .travis.yml +include Makefile +include tox.ini +recursive-include Images *.bdf +recursive-include Images *.fli +recursive-include Images *.gif +recursive-include Images *.ico +recursive-include Images *.jpg +recursive-include Images *.pbm +recursive-include Images *.pil +recursive-include Images *.png +recursive-include Images *.ppm +recursive-include Images *.psd +recursive-include Images *.tar +recursive-include Images *.webp +recursive-include Images *.xpm +recursive-include Sane *.c +recursive-include Sane *.py +recursive-include Sane *.txt +recursive-include Sane CHANGES +recursive-include Sane README +recursive-include Scripts *.py +recursive-include Scripts README +recursive-include Tests *.bin +recursive-include Tests *.icm +recursive-include Tests *.jpg +recursive-include Tests *.pcf +recursive-include Tests *.pcx +recursive-include Tests *.png +recursive-include Tests *.ppm +recursive-include Tests *.py +recursive-include Tests *.tif +recursive-include Tests *.tiff +recursive-include Tests *.ttf +recursive-include Tests *.txt +recursive-include Tk *.c +recursive-include Tk *.txt +recursive-include docs *.bat +recursive-include docs *.gitignore +recursive-include docs *.py +recursive-include docs *.rst +recursive-include docs Makefile +recursive-include docs BUILDME +recursive-include docs COPYING +recursive-include docs LICENSE +recursive-include libImaging *.c +recursive-include libImaging *.h diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..dca36d4ed --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +pre: + bin/python setup.py develop + bin/python selftest.py + bin/python Tests/run.py + check-manifest + pyroma . + viewdoc diff --git a/PIL/Image.py b/PIL/Image.py index 2e120e500..56a4b7093 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -224,6 +224,18 @@ _MODE_CONV = { "RGBA": ('|u1', 4), "CMYK": ('|u1', 4), "YCbCr": ('|u1', 3), + "I;16": ('=u2', None), + "I;16B": ('>u2', None), + "I;16L": ('i2', None), + "I;16LS": ('u4', None), + "I;32L": ('i4', None), + "I;32LS": ('= 2.0.0 supports Python versions 2.6, 2.7, 3.2, 3.3. +*Python Imaging Library (Fork)* -.. Note:: Pillow >= 2.1.0 no longer supports "import _imaging". Please use "from PIL.Image import core as _imaging" instead. +Pillow is the "friendly" PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors. .. image:: https://travis-ci.org/python-imaging/Pillow.png :target: https://travis-ci.org/python-imaging/Pillow -Pillow is the "friendly" PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors. - Introduction ------------ +.. Note:: Pillow >= 2.1.0 no longer supports "import _imaging". Please use "from PIL.Image import core as _imaging" instead. + +.. Note:: Pillow < 2.0.0 supports Python versions 2.4, 2.5, 2.6, 2.7; Pillow >= 2.0.0 supports Python versions 2.6, 2.7, 3.2, 3.3. + The fork author's goal is to foster active development of PIL through: - Continuous integration testing via `Travis CI `_ @@ -45,21 +47,30 @@ Installation .. Note:: PIL and Pillow currently cannot co-exist in the same environment. If you want to use Pillow, please remove PIL first. -TL;DR: - -:: +You can install Pillow with ``pip``:: $ pip install Pillow -For more information, please see http://python-imaging.github.io/ or below. +Or ``easy_install`` (for installing `Python Eggs `_, as pip does not support them):: + + $ easy_install Pillow + +Or download the compressed archive from PyPI, extract it, and inside it run:: + + $ python setup.py install + +For more information, please see http://pillow.readthedocs.org/en/latest/ or below. Documentation ------------- The API documentation included with PIL has been converted (from HTML generated by pythondoc) to reStructured text (via pandoc) and is now `hosted by readthedocs.org `_. This is a work in progress: in order to re-generate new API documentation, either `pythondoc `_ will have to be run again or the pythondoc functionality must be converted to Sphinx. -Community ---------- +Community Support +----------------- + +Developer +~~~~~~~~~ PIL needs you! Please help us maintain the Python Imaging Library here: @@ -67,14 +78,12 @@ PIL needs you! Please help us maintain the Python Imaging Library here: - Freenode (irc://irc.freenode.net#pil) - Image-SIG (http://mail.python.org/mailman/listinfo/image-sig) -Support -~~~~~~~ +Financial +~~~~~~~~~ -If you don't want to help with development, you can help us financially. Your donation will be very much appreciated. +Pillow is a volunteer effort led by Alex Clark. If you can't help with development, please help us financially; your assistance is very much needed and appreciated! -.. Note:: New contributors: please add your name (and donation preference) here and send a pull request. - -Pillow is a (labor of love) volunteer effort led by Alex Clark. Any contributor interested in receiving donations for their Pillow contributions may add their name (and donation preference) here. +.. Note:: Contributors: please add your name and donation preference here. +--------------------------------------+---------------------------------------+ | **Developer** | **Preference** | @@ -82,15 +91,15 @@ Pillow is a (labor of love) volunteer effort led by Alex Clark. Any contributor | Alex Clark (fork author) | http://gittip.com/aclark4life | +--------------------------------------+---------------------------------------+ -Developer ---------- +Developer Notes +--------------- .. Note:: If there is a binary package for your system, that is the easiest way to install Pillow. Currently we only provide binaries for Windows (via Python eggs). Build from source ~~~~~~~~~~~~~~~~~ -Some (most?) of Pillow's features require external libraries. +Many of Pillow's features require external libraries: * **libjpeg** provides JPEG functionality. @@ -122,7 +131,7 @@ Platform-specific instructions Linux +++++ -**We don't currently provide binaries for Linux.** If you didn't build Python from source, make sure you have Python's development libraries installed. In Debian or Ubuntu:: +**We do not provide binaries for Linux.** If you didn't build Python from source, make sure you have Python's development libraries installed. In Debian or Ubuntu:: $ sudo apt-get install python-dev python-setuptools @@ -141,7 +150,7 @@ Prerequisites are installed with on **Ubuntu 12.04 LTS** or **Raspian Wheezy 7.0 Mac OS X ++++++++ -**We don't currently provide binaries for OS X.** So you'll need XCode to install Pillow. (XCode 4.2 on 10.6 will work with the Official Python binary distribution. Otherwise, use whatever XCode you used to compile Python.) +**We do not provide binaries for OS X.** So you'll need XCode to install Pillow. (XCode 4.2 on 10.6 will work with the Official Python binary distribution. Otherwise, use whatever XCode you used to compile Python.) The easiest way to install the prerequisites is via `Homebrew `_. After you install Homebrew, run:: @@ -154,12 +163,26 @@ If you've built your own Python, then you should be able to install Pillow using Windows +++++++ -.. Note:: Since pip does not support eggs we use easy_install instead. +We provide binaries for Windows in the form of Python Eggs and `Python Wheels `_: + +Python Eggs +^^^^^^^^^^^ + +.. Note:: Pip does not support Python Eggs; use easy_install instead. :: $ easy_install Pillow +Python Wheels +^^^^^^^^^^^^^ + +.. Note:: Experimental. Requires Setuptools >=0.8 and Pip >=1.4.1 + +:: + + $ pip install --use-wheel Pillow + Platform support ~~~~~~~~~~~~~~~~ @@ -167,33 +190,33 @@ Current platform support for Pillow. Binary distributions are contributed for ea .. Note:: Contributors please test on your platform, edit this document and send a pull request -+----------------------------------+-------------+------------------------------+-----------------------+ -|**Operating system** |**Supported**|**Tested Python versions** |**Tested processors** | -+----------------------------------+-------------+------------------------------+-----------------------+ -| CentOS 6.3 |Yes | 2.7,3.3 |x86 | -+----------------------------------+-------------+------------------------------+-----------------------+ -| Mac OS X 10.8 Mountain Lion |Yes | 2.6,2.7,3.2,3.3 |x86-64 | -+----------------------------------+-------------+------------------------------+-----------------------+ -| Mac OS X 10.7 Lion |Yes | 2.7 |x86-64 | -+----------------------------------+-------------+------------------------------+-----------------------+ -| Redhat Linux 6 |Yes | 2.6 |x86 | -+----------------------------------+-------------+------------------------------+-----------------------+ -| Ubuntu Linux 10.04 LTS |Yes | 2.6 |x86,x86-64 | -+----------------------------------+-------------+------------------------------+-----------------------+ -| Ubuntu Linux 12.04 LTS |Yes | 2.6,2.7,3.2,3.3 |x86,x86-64 | -+----------------------------------+-------------+------------------------------+-----------------------+ -| Raspian Wheezy |Yes | 2.7,3.2 |arm | -+----------------------------------+-------------+------------------------------+-----------------------+ -| Gentoo Linux |Yes | 2.7,3.2 |x86-64 | -+----------------------------------+-------------+------------------------------+-----------------------+ -| Windows 7 Pro |Yes | 2.7,3.2 |x86 | -+----------------------------------+-------------+------------------------------+-----------------------+ -| Windows Server 2008 R2 Enterprise|Yes | 3.3 |x86-64 | -+----------------------------------+-------------+------------------------------+-----------------------+ -| Windows 8 Pro |Yes | 2.6,2.7,3.2,3.3,PyPy1.9 [1]_ |x86 [2]_,x86-64 | -+----------------------------------+-------------+------------------------------+-----------------------+ ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +|**Operating system** |**Supported**|**Tested Python versions** |**Tested Pillow versions** |**Tested processors** | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| CentOS 6.3 |Yes | 2.7,3.3 | |x86 | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| Mac OS X 10.8 Mountain Lion |Yes | 2.6,2.7,3.2,3.3 | |x86-64 | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| Mac OS X 10.7 Lion |Yes | 2.7 | 2.2.0 |x86-64 | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| Redhat Linux 6 |Yes | 2.6 | |x86 | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| Ubuntu Linux 10.04 LTS |Yes | 2.6 | 2.2.0 |x86,x86-64 | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| Ubuntu Linux 12.04 LTS |Yes | 2.6,2.7,3.2,3.3 | 2.2.0 |x86,x86-64 | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| Raspian Wheezy |Yes | 2.7,3.2 | 2.2.0 |arm | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| Gentoo Linux |Yes | 2.7,3.2 | 2.1.0 |x86-64 | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| Windows 7 Pro |Yes | 2.7,3.2 | |x86 | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| Windows Server 2008 R2 Enterprise|Yes | 3.3 | |x86-64 | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ +| Windows 8 Pro |Yes | 2.6,2.7,3.2,3.3,PyPy1.9 [1]_ | 2.2.0 |x86 [2]_,x86-64 | ++----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ -.. [1] x86 only +.. [1] x86 only, 2.1.0 tested .. [2] In some cases, x86 support may indicate 32-bit compilation on 64-bit architecture (vs. compilation on 32-bit hardware). Port existing PIL-based code to Pillow diff --git a/Tests/images/pngtest_bad.png.base64 b/Tests/images/pngtest_bad.png.base64 deleted file mode 100644 index 44e85d644..000000000 --- a/Tests/images/pngtest_bad.png.base64 +++ /dev/null @@ -1,151 +0,0 @@ -iVBORw0KGgoAAAANSUhEUgAAAFsAAABFCA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3+NL5848PB9MQIoXNB7Py2z1LIUSq8fy6//H578hifa9u0tLX -3rcPOYmtPbsBGaSuPZLSc5PSZZF1b03kdDI3dyk6V9J/OCj8GoNY4y9aC6bd4dUdT8p4k1Qhzj48 -nXTqGCst72ZKvgt5r51d19FZlVhAVgl5lnHVXHeQWKOQ1s5WIZHlqxCZXLrDux4rAknR9/ft1Lbt -BXVMRdhLX28Kq1f+zVTvt8mHpxPzzZ/67uQ9zYhsTIhrHYZpn+uyVrJvqzURwdXhVqfvq5Ir6R8N -i2lG8uoA00s/1hlMrvxZjNHf1W/6pyrv5SBtrvqfHA2nrt3ZpY8onRDBECO+iZg2jX9TmPafWd45 -qelZdXL8N/unLxcRI5KA96+XCfwHdncFlsvZ51/Uvxj/+jf/NS6XX/4B5/0nKd+4s0d9ez6w+cjo -DFc3s0tXTeeuPvchuLdRDf4sr8v/A0hBK/T1IM6VAAAAxnpUWHREZXNjcmlwdGlvbgAAeJxNy0FK -xEAQBdB9TvGXCjNhQPAE4k4d4hDXPd0/SUFS1XRVRnJ7t779G6iFjQX3A1c2Fw9qJmzCKC6meIrt -GUM6cGsps3Ujm4spXvrLCbuLzoiFuMlGxyd/MdiWFJNpIGnB28f7j1l57btv0Uxcv8bzkA4Uo0Mt -UKQxr3HA91qtBUSDbU2ZBbZH3ePUxSKOSVZiSY47qcimD7ZgQRiS/l+ypZl4SELqqnmca7NMd9EZ -Hqz9H24IVyP3c8UAAAAAAElFTkSuQmCC diff --git a/Tests/images/pngtest_bad.png.bin b/Tests/images/pngtest_bad.png.bin new file mode 100644 index 000000000..07a74a104 Binary files /dev/null and b/Tests/images/pngtest_bad.png.bin differ diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 067ea5812..5ae726ad8 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -212,18 +212,14 @@ def test_roundtrip_text(): def test_scary(): # Check reading of evil PNG file. For information, see: # http://scary.beasts.org/security/CESA-2004-001.txt + # The first byte is removed from pngtest_bad.png + # to avoid classification as malware. - import base64 - file = "Tests/images/pngtest_bad.png.base64" - data = None + with open("Tests/images/pngtest_bad.png.bin", 'rb') as fd: + data = b'\x89' + fd.read() - if py3: - data = base64.decodebytes(open(file, 'rb').read()) - else: - data = base64.decodestring(open(file, 'rb').read()) - - file = BytesIO(data) - assert_exception(IOError, lambda: Image.open(file)) + pngfile = BytesIO(data) + assert_exception(IOError, lambda: Image.open(pngfile)) def test_trns_rgb(): # Check writing and reading of tRNS chunks for RGB images. diff --git a/Tests/test_file_webp_metadata.py b/Tests/test_file_webp_metadata.py index a9c566cf4..031865bd7 100644 --- a/Tests/test_file_webp_metadata.py +++ b/Tests/test_file_webp_metadata.py @@ -9,10 +9,6 @@ try: except: skip('webp support not installed') -try: - from StringIO import StringIO -except ImportError: - from io import StringIO def test_read_exif_metadata(): @@ -40,7 +36,7 @@ def test_write_exif_metadata(): image = Image.open(file_path) expected_exif = image.info['exif'] - buffer = StringIO() + buffer = BytesIO() image.save(buffer, "webp", exif=expected_exif) @@ -73,7 +69,7 @@ def test_write_icc_metadata(): image = Image.open(file_path) expected_icc_profile = image.info['icc_profile'] - buffer = StringIO() + buffer = BytesIO() image.save(buffer, "webp", icc_profile=expected_icc_profile) diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py index 7d4b6d9b3..31516d978 100644 --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -2,4 +2,81 @@ from tester import * from PIL import Image -success() +def test_extent(): + im = lena('RGB') + (w,h) = im.size + transformed = im.transform(im.size, Image.EXTENT, + (0,0, + w//2,h//2), # ul -> lr + Image.BILINEAR) + + + scaled = im.resize((w*2, h*2), Image.BILINEAR).crop((0,0,w,h)) + + assert_image_similar(transformed, scaled, 10) # undone -- precision? + +def test_quad(): + # one simple quad transform, equivalent to scale & crop upper left quad + im = lena('RGB') + (w,h) = im.size + transformed = im.transform(im.size, Image.QUAD, + (0,0,0,h//2, + w//2,h//2,w//2,0), # ul -> ccw around quad + Image.BILINEAR) + + scaled = im.resize((w*2, h*2), Image.BILINEAR).crop((0,0,w,h)) + + assert_image_equal(transformed, scaled) + +def test_mesh(): + # this should be a checkerboard of halfsized lenas in ul, lr + im = lena('RGBA') + (w,h) = im.size + transformed = im.transform(im.size, Image.MESH, + [((0,0,w//2,h//2), # box + (0,0,0,h, + w,h,w,0)), # ul -> ccw around quad + ((w//2,h//2,w,h), # box + (0,0,0,h, + w,h,w,0))], # ul -> ccw around quad + Image.BILINEAR) + + #transformed.save('transformed.png') + + scaled = im.resize((w//2, h//2), Image.BILINEAR) + + checker = Image.new('RGBA', im.size) + checker.paste(scaled, (0,0)) + checker.paste(scaled, (w//2,h//2)) + + assert_image_equal(transformed, checker) + + # now, check to see that the extra area is (0,0,0,0) + blank = Image.new('RGBA', (w//2,h//2), (0,0,0,0)) + + assert_image_equal(blank, transformed.crop((w//2,0,w,h//2))) + assert_image_equal(blank, transformed.crop((0,h//2,w//2,h))) + + +def test_blank_fill(): + # attempting to hit + # https://github.com/python-imaging/Pillow/issues/254 reported + # + # issue is that transforms with transparent overflow area + # contained junk from previous images, especially on systems with + # constrained memory. So, attempt to fill up memory with a + # pattern, free it, and then run the mesh test again. Using a 1Mp + # image with 4 bands, for 4 megs of data allocated, x 64. OMM (64 + # bit 12.04 VM with 512 megs available, this fails with Pillow < + # a0eaf06cc5f62a6fb6de556989ac1014ff3348ea + # + # Running by default, but I'd totally understand not doing it in + # the future + + foo = [Image.new('RGBA',(1024,1024), (a,a,a,a)) + for a in range(1,65)] + + # Yeah. Watch some JIT optimize this out. + foo = None + + test_mesh() diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 838075c4c..85940d087 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -71,8 +71,8 @@ def test_render_equal(): def test_render_multiline(): im = Image.new(mode='RGB', size=(300,100)) - ttf = ImageFont.truetype(font_path, font_size) draw = ImageDraw.Draw(im) + ttf = ImageFont.truetype(font_path, font_size) line_spacing = draw.textsize('A', font=ttf)[1] + 8 lines = ['hey you', 'you are awesome', 'this looks awkward'] y = 0 @@ -80,8 +80,13 @@ def test_render_multiline(): draw.text((0, y), line, font=ttf) y += line_spacing + target = 'Tests/images/multiline_text.png' target_img = Image.open(target) - - assert_image_equal(im, target_img) + + # some versions of freetype have different horizontal spacing. + # setting a tight epsilon, I'm showing the original test failure + # at epsilon = ~38. + assert_image_similar(im, target_img,.5) + diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py index b9cacf0bb..377595751 100644 --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -1,6 +1,7 @@ from tester import * from PIL import Image +import struct try: import site @@ -56,9 +57,52 @@ def test_numpy_to_image(): assert_image(to_image(numpy.uint8, 4), "RGBA", (10, 10)) -# based on an erring example at http://is.gd/6F0esS +# based on an erring example at http://is.gd/6F0esS (which resolves to) +# http://stackoverflow.com/questions/10854903/what-is-causing-dimension-dependent-attributeerror-in-pil-fromarray-function def test_3d_array(): a = numpy.ones((10, 10, 10), dtype=numpy.uint8) assert_image(Image.fromarray(a[1, :, :]), "L", (10, 10)) assert_image(Image.fromarray(a[:, 1, :]), "L", (10, 10)) assert_image(Image.fromarray(a[:, :, 1]), "L", (10, 10)) + + +def _test_img_equals_nparray(img, np): + assert_equal(img.size, np.shape[0:2]) + px = img.load() + for x in range(0, img.size[0], int(img.size[0]/10)): + for y in range(0, img.size[1], int(img.size[1]/10)): + assert_deep_equal(px[x,y], np[y,x]) + + +def test_16bit(): + img = Image.open('Tests/images/12bit.cropped.tif') + np_img = numpy.array(img) + _test_img_equals_nparray(img, np_img) + assert_equal(np_img.dtype, numpy.dtype('uint16')) + +def test_to_array(): + + def _to_array(mode, dtype): + img = lena(mode) + np_img = numpy.array(img) + _test_img_equals_nparray(img, np_img) + assert_equal(np_img.dtype, numpy.dtype(dtype)) + + + modes = [("L", 'uint8'), + ("I", 'int32'), + ("F", 'float32'), + ("RGB", 'uint8'), + ("RGBA", 'uint8'), + ("RGBX", 'uint8'), + ("CMYK", 'uint8'), + ("YCbCr", 'uint8'), + ("I;16", 'uint16'), + ("I;16B", '>u2'), + ("I;16L", 'uint16'), + ] + + + for mode in modes: + assert_no_exception(lambda: _to_array(*mode)) + diff --git a/Tests/tester.py b/Tests/tester.py index 109265120..5f322cc20 100644 --- a/Tests/tester.py +++ b/Tests/tester.py @@ -67,6 +67,19 @@ def assert_equal(a, b, msg=None): else: failure(msg or "got %r, expected %r" % (a, b)) +def assert_deep_equal(a, b, msg=None): + try: + if len(a) == len(b): + if all([x==y for x,y in zip(a,b)]): + success() + else: + failure(msg or "got %s, expected %s" % (a,b)) + else: + failure(msg or "got length %s, expected %s" % (len(a), len(b))) + except: + assert_equal(a,b,msg) + + def assert_match(v, pattern, msg=None): import re if re.match(pattern, v): diff --git a/_imaging.c b/_imaging.c index 84f06e9df..e792ebfa5 100644 --- a/_imaging.c +++ b/_imaging.c @@ -71,7 +71,7 @@ * See the README file for information on usage and redistribution. */ -#define PILLOW_VERSION "2.1.0" +#define PILLOW_VERSION "2.2.1" #include "Python.h" diff --git a/docs/conf.py b/docs/conf.py index 7d9b76698..972984f82 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,9 +48,9 @@ copyright = u'1997-2011 by Secret Labs AB, 1995-2011 by Fredrik Lundh, 2010-2013 # built documents. # # The short X.Y version. -version = '2.1.0' +version = '2.2.0' # The full version, including alpha/beta/rc tags. -release = '2.1.0' +release = '2.2.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/libImaging/QuantTypes.h b/libImaging/QuantTypes.h index 8f113b082..411485498 100644 --- a/libImaging/QuantTypes.h +++ b/libImaging/QuantTypes.h @@ -14,6 +14,7 @@ #ifdef _MSC_VER typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; #else #include #endif diff --git a/libImaging/Storage.c b/libImaging/Storage.c index 7f2a455fa..eb3be4322 100644 --- a/libImaging/Storage.c +++ b/libImaging/Storage.c @@ -36,6 +36,7 @@ #include "Imaging.h" +#include int ImagingNewCount = 0; @@ -333,6 +334,7 @@ ImagingNewBlock(const char *mode, int xsize, int ysize) im->block = (char *) malloc(bytes); if (im->block) { + memset(im->block, 0, bytes); for (y = i = 0; y < im->ysize; y++) { im->image[y] = im->block + i; diff --git a/setup.py b/setup.py index 3bd822bf6..ad1dbdb49 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,11 @@ +# > pyroma . +# ------------------------------ +# Checking . +# Found Pillow +# ------------------------------ +# Final rating: 10/10 +# Your cheese is so fresh most people think it's a cream: Mascarpone +# ------------------------------ from __future__ import print_function import glob import os @@ -74,7 +82,7 @@ except ImportError: NAME = 'Pillow' -VERSION = '2.1.0' +VERSION = '2.2.1' TCL_ROOT = None JPEG_ROOT = None ZLIB_ROOT = None @@ -169,13 +177,17 @@ class pil_build_ext(build_ext): # freetype2 ships with X11 _add_directory(library_dirs, "/usr/X11/lib") _add_directory(include_dirs, "/usr/X11/include") - # if brew is installed, use its lib and include directories - import commands - status, homebrew = commands.getstatusoutput('brew --prefix') - if status == 0: - _add_directory(library_dirs, os.path.join(homebrew, 'lib')) - _add_directory(include_dirs, os.path.join(homebrew, 'include')) - + # if homebrew is installed, use its lib and include directories + import subprocess + try: + prefix = subprocess.check_output(['brew', '--prefix']) + if prefix: + prefix = prefix.strip() + _add_directory(library_dirs, os.path.join(prefix, 'lib')) + _add_directory(include_dirs, os.path.join(prefix, 'include')) + except: + pass # homebrew not installed + elif sys.platform.startswith("linux"): for platform_ in (plat.processor(), plat.architecture()[0]): @@ -560,7 +572,7 @@ class pil_build_ext(build_ext): setup( name=NAME, version=VERSION, - description='Python Imaging Library (fork)', + description='Python Imaging Library (Fork)', long_description=( _read('README.rst') + b'\n' + _read('CHANGES.rst') + b'\n' + @@ -586,10 +598,8 @@ setup( ext_modules=[Extension("PIL._imaging", ["_imaging.c"])], include_package_data=True, packages=find_packages(), - provides=[ - 'PIL' - ], scripts=glob.glob("Scripts/pil*.py"), + test_suite='PIL.tests', keywords=["Imaging",], license='Standard PIL License', zip_safe=True,