diff --git a/.travis.yml b/.travis.yml index 738b94b71..b4b98e784 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: python notifications: irc: "chat.freenode.net#pil" -env: MAX_CONCURRENCY=4 NOSE_PROCESSES=4 NOSE_PROCESS_TIMEOUT=30 +env: MAX_CONCURRENCY=4 python: - "pypy" @@ -14,9 +14,9 @@ python: - 3.4 install: - - "sudo apt-get -qq install libfreetype6-dev liblcms2-dev python-qt4 ghostscript libffi-dev cmake imagemagick" + - "sudo apt-get -qq install libfreetype6-dev liblcms2-dev python-qt4 ghostscript libffi-dev libjpeg-turbo-progs cmake imagemagick" - "pip install cffi" - - "pip install coveralls nose pyroma nose-cov" + - "pip install coveralls nose pyroma" - if [ "$TRAVIS_PYTHON_VERSION" == "2.6" ]; then pip install unittest2; fi # webp @@ -35,17 +35,22 @@ script: - if [ "$TRAVIS_PYTHON_VERSION" == "pypy" ]; then time nosetests Tests/test_*.py; fi # Cover the others - - if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then coverage run --parallel-mode --include=PIL/* selftest.py; fi - # write html report, then ignore. Coverage needs to be combined first - - if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then nosetests --with-cov --cov='PIL/' --cov-report=html Tests/test_*.py; fi + - if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then time coverage run --append --include=PIL/* selftest.py; fi + - if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then time coverage run --append --include=PIL/* -m nose Tests/test_*.py; fi after_success: - - ls -l .coverage* - - coverage combine - coverage report - - coveralls + # No need to send empty coverage to Coveralls for PyPy + - if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then coveralls; fi + - pip install pep8 pyflakes - pep8 --statistics --count PIL/*.py - pep8 --statistics --count Tests/*.py - pyflakes PIL/*.py | tee >(wc -l) - pyflakes Tests/*.py | tee >(wc -l) + + + # Coverage and quality reports on just the latest diff. + # (Installation is very slow on Py3, so just do it for Py2.) + - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then Scripts/diffcover-install.sh; fi + - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then Scripts/diffcover-run.sh; fi diff --git a/CHANGES.rst b/CHANGES.rst index f19ae0683..b80639db7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,7 @@ Changelog (Pillow) ================== -2.5.0 (unreleased) +2.5.0 (2014-07-01) ------------------ - Imagedraw rewrite diff --git a/PIL/Jpeg2KImagePlugin.py b/PIL/Jpeg2KImagePlugin.py index 66069802e..0a7a6e297 100644 --- a/PIL/Jpeg2KImagePlugin.py +++ b/PIL/Jpeg2KImagePlugin.py @@ -172,18 +172,16 @@ class Jpeg2KImageFile(ImageFile.ImageFile): fd = -1 length = -1 - if hasattr(self.fp, "fileno"): + try: + fd = self.fp.fileno() + length = os.fstat(fd).st_size + except: + fd = -1 try: - fd = self.fp.fileno() - length = os.fstat(fd).st_size - except: - fd = -1 - elif hasattr(self.fp, "seek"): - try: - pos = f.tell() - f.seek(0, 2) - length = f.tell() - f.seek(pos, 0) + pos = self.fp.tell() + self.fp.seek(0, 2) + length = self.fp.tell() + self.fp.seek(pos, 0) except: length = -1 diff --git a/Scripts/diffcover-install.sh b/Scripts/diffcover-install.sh new file mode 100755 index 000000000..93e06efe3 --- /dev/null +++ b/Scripts/diffcover-install.sh @@ -0,0 +1,7 @@ +# Fetch the remote master branch before running diff-cover on Travis CI. +# https://github.com/edx/diff-cover#troubleshooting +git fetch origin master:refs/remotes/origin/master + +# CFLAGS=-O0 means build with no optimisation. +# Makes build much quicker for lxml and other dependencies. +time CFLAGS=-O0 pip install --use-wheel diff_cover diff --git a/Scripts/diffcover-run.sh b/Scripts/diffcover-run.sh new file mode 100755 index 000000000..02efab6ae --- /dev/null +++ b/Scripts/diffcover-run.sh @@ -0,0 +1,4 @@ +coverage xml +diff-cover coverage.xml +diff-quality --violation=pyflakes +diff-quality --violation=pep8 diff --git a/Tests/test_file_jpeg2k.py b/Tests/test_file_jpeg2k.py index b763687f7..23564c434 100644 --- a/Tests/test_file_jpeg2k.py +++ b/Tests/test_file_jpeg2k.py @@ -39,6 +39,13 @@ class TestFileJpeg2k(PillowTestCase): self.assertEqual(im.size, (640, 480)) self.assertEqual(im.format, 'JPEG2000') + def test_bytesio(self): + with open('Tests/images/test-card-lossless.jp2', 'rb') as f: + data = BytesIO(f.read()) + im = Image.open(data) + im.load() + self.assert_image_similar(im, test_card, 1.0e-3) + # These two test pre-written JPEG 2000 files that were not written with # PIL (they were made using Adobe Photoshop) diff --git a/docs/_templates/sidebarhelp.html b/docs/_templates/sidebarhelp.html index ce36d2e34..e07180a99 100644 --- a/docs/_templates/sidebarhelp.html +++ b/docs/_templates/sidebarhelp.html @@ -1,18 +1,4 @@

Need help?

-

- You can seek realtime assistance via IRC at - irc://irc.freenode.net#pil. You can - also post to the - - Image-SIG mailing list. And, of course, there's - - Stack Overflow. + You can get help via IRC at irc://irc.freenode.net#pil or Stack Overflow here and here. Please report issues on GitHub.

- -

- If you've discovered a bug, you can - open an issue - on Github. -

- diff --git a/docs/about.rst b/docs/about.rst index 817773610..919b2918c 100644 --- a/docs/about.rst +++ b/docs/about.rst @@ -9,12 +9,10 @@ The fork authors' goal is to foster active development of PIL through: - Continuous integration testing via `Travis CI`_ - Publicized development activity on `GitHub`_ - Regular releases to the `Python Package Index`_ -- Solicitation for community contributions and involvement on `Image-SIG`_ .. _Travis CI: https://travis-ci.org/python-pillow/Pillow .. _GitHub: https://github.com/python-pillow/Pillow .. _Python Package Index: https://pypi.python.org/pypi/Pillow -.. _Image-SIG: http://mail.python.org/mailman/listinfo/image-sig License ------- diff --git a/docs/index.rst b/docs/index.rst index a8c204228..16e450856 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,8 +1,7 @@ Pillow ====== -Pillow is the 'friendly' PIL fork by Alex Clark and Contributors. PIL is the -Python Imaging Library by Fredrik Lundh and Contributors. +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-pillow/Pillow.svg?branch=master :target: https://travis-ci.org/python-pillow/Pillow @@ -20,12 +19,7 @@ Python Imaging Library by Fredrik Lundh and Contributors. :target: https://coveralls.io/r/python-pillow/Pillow?branch=master :alt: Test coverage -To start using Pillow, please read the :doc:`installation -instructions `. - -You can get the source and contribute at -https://github.com/python-pillow/Pillow. You can download archives -and old versions from `PyPI `_. +To install Pillow, please follow the :doc:`installation instructions `. To download source and/or contribute to development of Pillow please see: https://github.com/python-pillow/Pillow. .. toctree:: :maxdepth: 2 @@ -37,30 +31,6 @@ and old versions from `PyPI `_. handbook/appendices original-readme -Support Pillow! -=============== - -PIL needs you! Please help us maintain the Python Imaging Library here: - -- `GitHub `_ -- `Freenode `_ -- `Image-SIG `_ - -Financial ---------- - -Pillow is a volunteer effort led by Alex Clark. If you can't help with -development please consider helping us financially. Your assistance would -be very much appreciated! - -.. note:: Contributors please add your name and donation preference here. - -======================================= ======================================= -**Developer** **Preference** -======================================= ======================================= -Alex Clark (fork author) http://gittip.com/aclark4life -======================================= ======================================= - Indices and tables ================== diff --git a/docs/installation.rst b/docs/installation.rst index 969a8ee8f..8abbd6679 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -44,6 +44,10 @@ run:: External libraries ------------------ +.. note:: + + You *do not* need to install all of the external libraries to use Pillow's basic features. + Many of Pillow's features require external libraries: * **libjpeg** provides JPEG functionality. @@ -92,11 +96,6 @@ Linux installation Fedora, Debian/Ubuntu, and ArchLinux include Pillow (instead of PIL) with their distributions. Consider using those instead of installing manually. -.. note:: - - You *do not* need to install all of the external libraries to get Pillow's - basics to work. - **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:: @@ -131,22 +130,13 @@ Prerequisites are installed on **Fedora 20** with:: Mac OS X installation --------------------- -.. note:: +We provide binaries for OS X in the form of `Python Wheels `_. Alternatively you can compile Pillow with with XCode. - You *do not* need to install all of the external libraries to get Pillow's - basics to work. - -**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:: +The easiest way to install external libraries is via `Homebrew `_. After you install Homebrew, run:: $ brew install libtiff libjpeg webp little-cms2 -If you've built your own Python, then you should be able to install Pillow -using:: +Install Pillow with:: $ pip install Pillow @@ -253,3 +243,8 @@ current versions of Linux, OS X, and Windows. +----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ | Windows 8.1 Pro |Yes | 2.6,2.7,3.2,3.3,3.4 | 2.3.0, 2.4.0 |x86,x86-64 | +----------------------------------+-------------+------------------------------+------------------------------+-----------------------+ + +Old Versions +------------ + +You can download old distributions from `PyPI `_. Only the latest 1.x and 2.x releases are visible, but all releases are available by direct URL access e.g. https://pypi.python.org/pypi/Pillow/1.0. diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index 6dcb73638..bf64c835d 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -49,7 +49,7 @@ Functions .. autofunction:: open - .. warning:: > To protect against potential DOS attacks caused by "[decompression bombs](https://en.wikipedia.org/wiki/Zip_bomb)" (i.e. malicious files which decompress into a huge amount of data and are designed to crash or cause disruption by using up a lot of memory), Pillow will issue a `DecompressionBombWarning` if the image is over a certain limit. If desired, the warning can be turned into an error with `warnings.simplefilter('error', Image.DecompressionBombWarning)` or suppressed entirely with `warnings.simplefilter('ignore', Image.DecompressionBombWarning)`. See also [the logging documentation](https://docs.python.org/2/library/logging.html?highlight=logging#integration-with-the-warnings-module) to have warnings output to the logging facility instead of stderr. + .. warning:: > To protect against potential DOS attacks caused by "`decompression bombs`_" (i.e. malicious files which decompress into a huge amount of data and are designed to crash or cause disruption by using up a lot of memory), Pillow will issue a `DecompressionBombWarning` if the image is over a certain limit. If desired, the warning can be turned into an error with `warnings.simplefilter('error', Image.DecompressionBombWarning)` or suppressed entirely with `warnings.simplefilter('ignore', Image.DecompressionBombWarning)`. See also `the logging documentation`_ to have warnings output to the logging facility instead of stderr. Image processing ^^^^^^^^^^^^^^^^