Commit Graph

2267 Commits

Author SHA1 Message Date
Will Badart
adae7ecc6a
_util.isPath returns True for pathlib.Path objects
Now, for functions which accept either a path or file object, the
predicate will pass on Paths and not attempt to call .read on them
before opening.

The pathlib module was added in 3.4 but os.path functions did not start
accepting path-like objects until 3.6, so that is the version after
which this implementation is defined.

Added a unit test to make sure isPath accepts Path objects. The unit
test is skipped if python version is not 3.6 or later.
2019-01-28 12:19:21 -05:00
Hugo
1b91ae361d
Merge pull request #3599 from hugovk/rm-deprecated-imageops
Remove deprecated ImageOps functions
2019-01-26 19:48:17 +02:00
Hugo
d6055440d5 Drop support for EOL Python 3.4 2019-01-24 23:33:14 +02:00
Hugo
b41ffe585b Remove deprecated ImageOps functions 2019-01-19 20:00:55 +02:00
Andrew Murray
0481d0ac1e Seek to IFD offset 2019-01-16 06:55:37 +11:00
Andrew Murray
06f47ea546 Revert "Use bare 'raise' to re-raise exceptions"
This reverts commit 80e96b2c7b.
2019-01-14 21:55:47 +11:00
Andrew Murray
811a6ae9f2
Merge pull request #3575 from jdufresne/bare-raise
Use bare 'raise' to re-raise exceptions
2019-01-14 15:39:20 +11:00
Jon Dufresne
7da17ad41e Improve pytest configuration to allow specific tests as CLI args
The previous test configuration made it difficult to run a single test
with the pytest CLI. There were two major issues:

- The Tests directory was not a package. It now includes a __init__.py
  file and imports from other tests modules are done with relative
  imports.

- setup.cfg always specified the Tests directory. So even if a specific
  test were specified as a CLI arg, this configuration would also always
  include all tests. This configuration has been removed to allow
  specifying a single test on the command line.

Contributors can now run specific tests with a single command such as:

  $ tox -e py37 -- Tests/test_file_pdf.py::TestFilePdf.test_rgb

This makes it easy and faster to iterate on a single test failure and is
very familiar to those that have previously used tox and pytest.

When running tox or pytest with no arguments, they still discover and
runs all tests in the Tests directory.
2019-01-13 09:00:12 -08:00
Jon Dufresne
80e96b2c7b Use bare 'raise' to re-raise exceptions
Slightly more concise and nicer syntax
2019-01-12 18:45:37 -08:00
Jon Dufresne
3e28ba3b7d Python del is a statement not a function
https://docs.python.org/3/reference/simple_stmts.html#the-del-statement
2019-01-12 18:28:35 -08:00
Jon Dufresne
a08bfa6e9f Make ContainerIO.isatty() return a bool, not int
Better follows the interface of IOBase.isatty:

https://docs.python.org/3/library/io.html#io.IOBase.isatty
2019-01-12 16:48:05 -08:00
Andrew Murray
7acaf3d6a6 Added support for I;16 modes for more transpose operations 2019-01-10 07:26:52 +11:00
Andrew Murray
4e0a73b4fa Allow for unknown PNG chunks after image data 2019-01-08 07:21:25 +11:00
Jon Dufresne
8a05aae988 Remove unused PillowTestCase.__str__
With the move to pytest, the class's string method is unused. pytest has
its own test progress outputter.
2019-01-06 15:18:18 -08:00
Hugo van Kemenade
4d1be57256
Merge pull request #3540 from radarhere/fp
Only close __fp if not fp
2019-01-06 12:53:04 +02:00
Hugo van Kemenade
22b0f53eb9
Merge pull request #3532 from radarhere/png_load_end_idat
PNG: Handle IDAT chunks after image end
2019-01-05 12:08:58 +02:00
Andrew Murray
71b64dcf73 Only close __fp if not fp 2019-01-04 12:29:23 +11:00
Andrew Murray
ea2a0e4654 Handle IDAT chunks after image end 2019-01-03 19:13:19 +11:00
hugovk
9dbaf92f3e itxt_chunks.png fails with protocol v2 2019-01-03 09:31:55 +11:00
hugovk
1b338998dc Test a png file with iTXt chunks 2019-01-03 09:31:55 +11:00
Andrew Murray
bd7422f934 Detect whether mimetype is image/jp2 or image/jpx 2019-01-02 15:39:39 +11:00
Andrew Murray
42e2bed4a6 If SGI image is RGB mode, then apply image/rgb mimetype 2019-01-02 14:13:37 +11:00
Andrew Murray
97ae0c42b1 Detect whether mimetype is image/png or image/apng 2019-01-02 14:13:10 +11:00
Andrew Murray
671f7a392d Allow RGBA value for P image putpixel 2018-12-31 13:37:04 +11:00
Andrew Murray
3f6282e259 Allow RGB value for P image putpixel 2018-12-31 11:35:15 +11:00
Andrew Murray
0c0f769351 Allow EPS tests that do not require Ghostscript 2018-12-30 20:50:09 +11:00
Hugo
454fdd7800
Merge pull request #3501 from pirate486743186/patch-2
Add APNG extension to PNG plugin
2018-12-29 16:55:07 +02:00
Andrew Murray
6ead422e91 Added custom string TIFF tags 2018-12-29 16:14:52 +11:00
Andrew Murray
21268c87b3
Merge branch 'master' into patch-2 2018-12-27 17:39:40 +11:00
Andrew Murray
f9ce201cf0 Test APNG image for similarity 2018-12-27 12:19:44 +11:00
pirate486743186
8d0b7e6b57 adding apng extension for png 2018-12-26 21:14:27 +01:00
Hugo
a43b8bac1e
Merge pull request #3506 from radarhere/png
Read textual chunks located after IDAT chunks for PNG
2018-12-26 13:34:50 +02:00
Hugo
78bc4da131
Merge pull request #3350 from radarhere/custom_tags
Added custom int and float TIFF tags
2018-12-26 13:07:46 +02:00
Hugo
bbb3be9a9d
Merge pull request #3187 from radarhere/encoderinfo
Wait until mode is normalized to copy im.info into encoderinfo
2018-12-26 12:56:50 +02:00
Andrew Murray
22837c37e2 Read textual chunks located after IDAT chunks 2018-12-24 23:58:19 +11:00
Hugo
3ed5dcc928
Merge pull request #3467 from hugovk/lint-can-fail
CI: Allow lint job to fail
2018-12-13 21:09:58 +02:00
Hugo
961fecb35c
Merge pull request #3261 from radarhere/fp
Resolve __fp when closing and deleting
2018-12-13 21:09:23 +02:00
Hugo
857b077f5c
Merge pull request #3461 from radarhere/exclusive_fp
Close exclusive fp before discarding
2018-12-13 21:07:32 +02:00
Konstantin Kopachev
e91b851fdc
Add reading old-JPEG compressed TIFFs
Old-style JPEG compression in TIFFs are able to be read using Strip/Tile APIs. Although, it should be possible to read them using Scanline API, it does not work for some reason.  Anyway, reading subsampled YCbCr formats through Strip/Tile/Scanline libtiff API does not de-subsample the data, so caller should unpack data to whatever format is appropriate.  New-style JPEG compressed images were already read through libtiff as RGB images (https://github.com/python-pillow/Pillow/pull/3227). Unfortunately, there is no flag to ask libtiff to de-subsample old jpeg, but it provides a way to read any image as 32bit RGBA.  This commit adds ability to read old-style JPEG TIFFs through reading *all* YCbCr images as RGBX using Tile and Strip reading API. This supersedes previous work (PR #3227) to read new-style JPEG-TIFFs.
2018-12-10 10:07:41 -08:00
Hugo
ffa4932ed0 noqa a pair of ambiguous variable names 2018-12-04 23:25:28 +02:00
Hugo
c353225851 Prefer 'except Exception:' to bare 'except:' 2018-12-04 23:25:28 +02:00
Hugo
e10b22aca2 Remove unused 'sys' import 2018-12-04 23:25:28 +02:00
Hugo
231604e921
Merge pull request #3471 from radarhere/background
Change color table index background to tuple when saving as WebP
2018-12-04 23:22:53 +02:00
Hugo
a4fccd3dde
Merge pull request #3479 from radarhere/gif_extension
Allow arbitrary number of comment extension subblocks
2018-12-04 23:09:59 +02:00
Hugo
0c2e4840f2
Merge pull request #3478 from radarhere/fli
Ensure previous FLI frame is loaded before seeking to the next
2018-12-04 22:51:54 +02:00
Hugo
5c16528fdf
Merge pull request #3450 from radarhere/imageshow
ImageShow improvements
2018-12-04 22:47:28 +02:00
Andrew Murray
b2b737b68b Allow arbitrary number of comment extension subblocks 2018-11-27 21:11:22 +11:00
Andrew Murray
f1b2802eb1 Resolved error for comment extension with zero subblocks 2018-11-27 21:09:28 +11:00
Andrew Murray
2f7f945c84 Ensure previous FLI frame is loaded before seeking to the next 2018-11-26 18:52:51 +11:00
Andrew Murray
6c126ca282 Change color table index background to tuple when saving 2018-11-20 19:50:14 +11:00
Andrew Murray
47775f3d50 Resolve __fp when closing and deleting 2018-11-17 21:56:06 +11:00
Hugo
9eb36da0b8
Merge pull request #3460 from radarhere/check_png_dos
Corrected TypeError in Python 3
2018-11-16 23:26:49 +02:00
Hugo
6a63693d23
Merge pull request #3459 from radarhere/core_resources
Added __main__ code to test_core_resources
2018-11-16 17:55:46 +02:00
Andrew Murray
61397de88b Check quality_layers type 2018-11-16 23:31:42 +11:00
Andrew Murray
c0ee319af1 Close fp before replacing 2018-11-13 22:24:59 +11:00
Andrew Murray
b637b5f7a2 Close exclusive fp before discarding 2018-11-13 22:13:55 +11:00
Andrew Murray
9a1c3915ae Corrected TypeError in Python 3 2018-11-13 21:45:52 +11:00
Andrew Murray
3ff4b54050 Added __main__ code 2018-11-12 19:54:26 +11:00
Andrew Murray
a0be7b09cc Added UnixViewer get_command 2018-11-12 19:33:57 +11:00
Andrew Murray
ddf8593e7b Do not write custom tags with libtiff < 4 2018-11-12 06:14:04 +11:00
Andrew Murray
a3d45e9cef Added custom int and float TIFF tags 2018-11-12 06:14:04 +11:00
Andrew Murray
990fb03218 Changed if to elif 2018-11-12 06:14:04 +11:00
Hugo
a568a8730e flake8: E302 expected 2 blank lines, found 1 2018-11-11 19:01:11 +02:00
Hugo
ceebfc6fe8 flake8: E501 line too long 2018-11-11 19:01:11 +02:00
Hugo
254f959c3a flake8: E127 continuation line over-indented for visual indent 2018-11-11 19:01:11 +02:00
Hugo
94c94eb1f7 flake8: E128 continuation line under-indented for visual indent 2018-11-11 19:01:11 +02:00
Hugo
717add44b0 flake8: E201 whitespace after '(' 2018-11-11 19:01:11 +02:00
Hugo
8a6f2b9de8 flake8: E711 comparison to None should be 'if cond is None:' 2018-11-11 19:01:10 +02:00
Hugo
eb9aee7048 flake8: F841 local variable is assigned to but never used 2018-11-11 19:01:10 +02:00
Hugo
302f86292c
Merge pull request #3392 from hugovk/update-tests
Update tests
2018-11-11 18:52:11 +02:00
Andrew Murray
52c175d1bc Added context manager, __del__ and close methods 2018-11-11 16:00:17 +11:00
Hugo
8feed91ec1
Merge pull request #3454 from radarhere/imagegrab
Do not play sound when running screencapture command
2018-11-10 12:48:01 +00:00
Andrew Murray
747eccbfc2 Close exclusive fp on open exception 2018-11-09 11:35:08 +11:00
Andrew Murray
40c6e4f136 Do not play sound when running screencapture command 2018-11-08 06:05:45 +11:00
Hugo
ed10276a6b
Merge pull request #3418 from radarhere/webp_fp
Only close existing fp in WebP if fp is exclusive
2018-10-31 09:16:53 +02:00
Hugo
e12aa375ec
Merge pull request #3406 from Nazime/negativeindex
Add negative index to PixelAccess
2018-10-27 23:27:15 +03:00
Hugo
4530f55c61
Merge pull request #3385 from radarhere/gif_background
Change tuple background to global color table index when saving as GIF
2018-10-24 22:34:40 +03:00
Hugo
5df41b4399 Unnecessary generator - rewrite as a list comprehension 2018-10-24 22:29:56 +03:00
Hugo
088d04470e Unnecessary list comprehension - 'tuple' can take a generator 2018-10-24 22:29:56 +03:00
Hugo
d69ef6a529 Remove redundant parentheses 2018-10-24 22:29:56 +03:00
Hugo
619e5fde8d Remove unused local variables 2018-10-24 22:29:01 +03:00
Hugo
bac99bd5ae Add assert for previously unused 'lut' variable 2018-10-24 22:29:01 +03:00
Hugo
4352edb1ec Assert all images in loop 2018-10-24 22:29:01 +03:00
Hugo
fc3a159c87 More specific exception clause 2018-10-24 22:29:01 +03:00
Hugo
cb8a4bac21 Use set literal 2018-10-24 22:29:01 +03:00
Hugo
bab194b6f5 Fix DeprecationWarning: invalid escape sequence 2018-10-24 22:29:01 +03:00
Hugo
a3b0659790 flake8 2018-10-24 22:29:01 +03:00
Hugo
d1ca4916e0 Use more specific assertions 2018-10-24 22:29:01 +03:00
Hugo
901c1e2aea Simplify test skipping 2018-10-24 22:29:01 +03:00
Andrew Murray
bd9cfb124b Added ImageGrab.grabclipboard test 2018-10-22 18:55:16 +11:00
Andrew Murray
467d2089be Enabled ImageGrab.grab test on AppVeyor 2018-10-22 18:39:07 +11:00
Andrew Murray
94925c5057
Merge pull request #3423 from hugovk/fix-feature-tests
Fix some tests
2018-10-22 08:53:26 +11:00
Hugo
06ad343d35 Simplify skipping 2018-10-21 17:47:35 +03:00
Hugo
e33812c56c Remove redundant parentheses 2018-10-21 17:05:40 +03:00
Hugo
cbba2c24bf Remove unused helper method 2018-10-21 17:05:14 +03:00
Hugo
cfc4c3e101 Switch check_ to test_ to enable them 2018-10-21 16:44:12 +03:00
Hugo
a1b9f94d60 skipUnless takes a condition and _reason_ 2018-10-21 16:42:41 +03:00
Andrew Murray
929f7397db Line too long 2018-10-21 18:26:08 +11:00
Andrew Murray
c7d924fd85 Too many blank lines 2018-10-21 18:11:50 +11:00
Andrew Murray
e84a78d828 Only close existing fp if fp is exclusive 2018-10-19 20:12:08 +11:00