Commit Graph

916 Commits

Author SHA1 Message Date
Hugo van Kemenade
29d36c9260
Merge pull request #4388 from jdufresne/str-bytes-shim
Remove leftover Python 2 compatibility shim
2020-01-29 14:41:59 +02:00
Hugo van Kemenade
659f73d0be
Merge pull request #4389 from jdufresne/make-bytes
Remove unnecessary make_bytes() function
2020-01-27 15:55:14 +02:00
Alexander Karpinsky
5965437402
Merge pull request #4370 from uploadcare/jpeg-multiple-app13
Handle multiple and malformed JPEG APP13 markers
2020-01-27 15:46:36 +03:00
Alexander Karpinsky
fd03a68c1a
Update comment
Co-Authored-By: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2020-01-27 15:18:02 +03:00
Jon Dufresne
c84c736e5b Remove unnecessary make_bytes() function
The function was introduced in 65112bad7e
to handle the differences between Python 2 & 3 byte handling. Now that
Python 3 supports byte formatting, can drop the unnecessary
compatibility shim in favor of native features.
2020-01-26 15:16:04 -08:00
Jon Dufresne
d57d02e827 Remove leftover Python 2 compatibility shim
In Python 3, __str__ should not return bytes.
2020-01-26 14:46:27 -08:00
Hugo van Kemenade
892aec306b
Merge pull request #4385 from jdufresne/try-block
Limit try block to code expected to raise an exception
2020-01-26 20:04:39 +02:00
Jon Dufresne
bd71374cd2 Limit try block to code expected to raise an exception
In the off chance that the additional code in decoder()/encoder() raise
a KeyError or AttributeError, a bug could be hidden.
2020-01-26 07:10:22 -08:00
Jon Dufresne
63729766c4 Remove unnecessary coerce to float
In Python 3, the division operator is floating point division. No longer
need to coerce integers to floating point numbers before division.
2020-01-26 06:33:18 -08:00
Andrew Murray
6a7ac38c6c extents are not used by map_buffer 2020-01-26 13:22:23 +11:00
Alexander
dcd0cd9129 update dict instead of ignoring 2020-01-19 14:53:46 +03:00
Alexander
f55eb73934 handle Photoshop chunks which can't be processed 2020-01-19 03:37:43 +03:00
Alexander
3841c96ec6 Cleanup code a bit 2020-01-19 03:15:37 +03:00
Andrew Murray
56f30ef792 Allow explicit zero width to hide outline 2020-01-08 21:55:15 +11:00
Andrew Murray
46b4caa8e3 7.1.0.dev0 version bump 2020-01-02 20:45:59 +11:00
Andrew Murray
37b1974d30 7.0.0 version bump 2020-01-02 15:33:48 +11:00
Andrew Murray
138bd714f5 Raise an error for an invalid number of bands in FPX image 2020-01-02 15:20:24 +11:00
Andrew Murray
4203845a24
Merge pull request #4320 from uploadcare/rgb2l-rounding-error
Fix rounding error on RGB to L conversion
2020-01-01 20:09:34 +11:00
Andrew Murray
e8bb2dd93e Allow string comment when saving GIF 2020-01-01 13:29:39 +11:00
Alexander
038f9daf27 bring ImageColor.getcolor into line with Convert.c implementation 2019-12-31 16:56:09 +03:00
Andrew Murray
8924054dd9 Changed _limit_signed_rational 2019-12-31 19:12:33 +11:00
Alexander
fa1deca144 Fix wrong tests 2019-12-31 04:12:50 +03:00
Andrew Murray
74d53bcd15 Lint fixes 2019-12-31 11:58:39 +11:00
Andrew Murray
6d3fb7b083
Merge branch 'master' into exif-writing-fixes 2019-12-31 11:38:33 +11:00
Andrew Murray
f72e866b5e
Merge pull request #4305 from radarhere/remove_distutils
Replaced distutils with C version check
2019-12-31 11:33:39 +11:00
Andrew Murray
f77c409742 Renamed variable 2019-12-31 09:04:25 +11:00
Alexander
c74c20eb9f Merge branch 'master' into reduce-in-resize
# Conflicts:
#	docs/releasenotes/7.0.0.rst
2019-12-30 03:24:38 +03:00
Alexander
34029e9af4 texts fixes 2019-12-30 03:23:30 +03:00
Andrew Murray
82356f7f36 Removed _libtiff_version 2019-12-28 12:57:13 +11:00
Andrew Murray
61d0784933 Allow loading of WMF images at a given DPI 2019-12-28 11:25:39 +11:00
Andrew Murray
34d04d3e82 Replaced distutils with C version check 2019-12-28 09:57:49 +11:00
Alexander
1bd9b16e97 wording 2019-12-27 15:35:17 +03:00
Alexander
222c2f6978 Merge branch 'master' into reduce-in-resize 2019-12-27 15:13:19 +03:00
Alexander Karpinsky
5f69035865
Merge pull request #4251 from uploadcare/reduce
Reduce operation
2019-12-27 15:11:47 +03:00
Alexander
fc0248869c wording 2019-12-27 14:27:37 +03:00
Andrew Murray
e446b58317 Lint fix 2019-12-26 20:21:16 +11:00
Andrew Murray
996f552f32
Highlight class name
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
2019-12-26 19:55:10 +11:00
Andrew Murray
c99257abb4
Updated error string
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
2019-12-26 19:54:28 +11:00
Andrew Murray
fedb0407b4 Raise ValueError for io.StringIO in Image.open 2019-12-26 18:53:06 +11:00
Andrew Murray
ca0209d194 Updated exception documentation [ci skip] 2019-12-26 13:16:49 +11:00
Hugo van Kemenade
0fe6955da5
Removed duplicate line (#4291)
Removed duplicate line
2019-12-25 14:55:25 +02:00
Alexander
d719aafecb Merge branch 'reduce' into reduce-in-resize
# Conflicts:
#	docs/releasenotes/7.0.0.rst
2019-12-25 15:45:17 +03:00
Alexander
dda5558129 Merge branch 'master' into reduce 2019-12-25 15:42:47 +03:00
Alexander Karpinsky
b5d06baa5f
Merge pull request #4231 from uploadcare/box-in-thumbnail
Fix thumbnail geometry when DCT scaling is used
2019-12-25 15:41:40 +03:00
Andrew Murray
ee30fe1b39
Merge pull request #4147 from beipang2/issue_4146
Use default DPI when exif provides invalid x_resolution
2019-12-25 20:26:27 +11:00
Andrew Murray
1740a1f20e Ensure tempfile is unlinked 2019-12-25 15:22:54 +11:00
Andrew Murray
c35fb6fb67
Merge branch 'master' into box-in-thumbnail 2019-12-24 18:18:34 +11:00
Andrew Murray
74a8034644 Updated draft documentation [ci skip] 2019-12-24 14:50:53 +11:00
Andrew Murray
6480d57c1f Removed duplicate line 2019-12-24 08:33:04 +11:00
Hugo
6a43ea86ea Merge remote-tracking branch 'upstream/master' into doctest-turn-warnings-into-errors 2019-12-21 15:52:59 +02:00
Hugo
113477fbee Fix unexpected unindents 2019-12-21 14:05:50 +02:00
Alexander
59f8eeb290 add release notes 2019-12-21 03:16:42 +03:00
Andrew Murray
4580b156b7 Raise an error if BMP file size is too large when saving 2019-12-21 08:37:40 +11:00
Andrew Murray
ce62dca326 Aligned comments correctly 2019-12-21 08:15:48 +11:00
Alexander
fc28182040 fix formatting 2019-12-20 20:42:00 +03:00
Alexander
8181aed77f Merge branch 'reduce' into reduce-in-resize
# Conflicts:
#	docs/releasenotes/7.0.0.rst
#	src/PIL/Image.py
2019-12-20 20:27:11 +03:00
Alexander
d41f2713b6 Merge branch 'master' into reduce 2019-12-20 20:22:36 +03:00
Alexander
b48996c213 rename max_reduce to reducing_gap 2019-12-20 14:59:18 +03:00
Alexander
b85c610a03 Use box for reduce 2019-12-20 14:54:06 +03:00
Alexander
b112e55070 Merge branch 'master' into box-in-thumbnail
# Conflicts:
#	docs/releasenotes/7.0.0.rst
2019-12-19 16:36:37 +03:00
Alexander Karpinsky
6d75a673b6
Merge pull request #4255 from uploadcare/default-resample-filter
Change default resize resampling filter from NEAREST to BICUBIC
2019-12-19 16:33:34 +03:00
Alexander
cdd1253211 notes fixes
skip-checks: true
2019-12-18 01:09:54 +03:00
Alexander
4da9858709 change default resampling filter for ImageOps.pad(), ImageOps.scale() and ImageOps.fit() 2019-12-17 18:15:02 +03:00
Alexander
fa9e85cd1f max_reduce arguments in resize and thumbnail 2019-12-17 03:01:51 +03:00
Alexander
2db5406626 Merge branch 'box-in-thumbnail' into reduce-in-resize-2 2019-12-17 02:27:44 +03:00
Alexander
ea9c6e9fe1 Merge branch 'master' into reduce 2019-12-17 02:26:05 +03:00
Alexander
a027897f74 Merge branch 'master' into box-in-thumbnail
# Conflicts:
#	Tests/test_image_thumbnail.py
2019-12-17 00:42:29 +03:00
Andrew Murray
c7bef264bc Allow thumbnail to accept non-integer size arguments 2019-12-17 06:05:36 +11:00
Alexander
791d1a2846 Better thumbnail aspect ratio preservation 2019-12-07 20:07:27 +03:00
Alexander
ac92836e81 Change default resize resampling filter 2019-12-07 18:08:19 +03:00
Alexander
5283141417 Merge branch 'master' into reduce 2019-12-05 14:23:28 +03:00
Alexander
778b5f9fed add box parameter 2019-12-04 23:13:20 +03:00
Andrew Murray
2d7cfc4bbc
Merge pull request #4239 from radarhere/photoshop
Handle broken Photoshop data
2019-12-01 07:33:26 +11:00
Alexander
4e092153fc add release notes 2019-11-30 18:17:10 +03:00
Andrew Murray
08cad40002
Merge pull request #4181 from pwohlhart/patch-1
Better error messaging in PIL.Image.fromarray
2019-11-30 21:12:05 +11:00
Andrew Murray
47b2ae9a63 Raise a specific exception if no data is found for an MPO frame 2019-11-30 11:05:36 +11:00
Andrew Murray
e51be50549 Handle broken Photoshop data 2019-11-30 10:08:32 +11:00
Alexander
8b6ad4a471 tests for supported modes 2019-11-26 03:39:57 +03:00
Alexander
335f5431de dummy method 2019-11-24 17:39:49 +03:00
Alexander
e234445682 linter fixes 2019-11-24 15:32:45 +03:00
Hugo van Kemenade
8626762024
Merge pull request #4174 from mixmastamyk/patch-1
Fix mismatched function name, add explanation
2019-11-24 13:54:22 +02:00
Alexander
fd21de7dc4 Merge branch 'refs/heads/master' into box-in-thumbnail
# Conflicts:
#	Tests/test_image_thumbnail.py
2019-11-24 05:27:13 +03:00
Alexander
375556ffb5 use a box from draft in thumbnail 2019-11-24 05:24:00 +03:00
Alexander
4126f6cdf7 return chosen image mode and the box of the image 2019-11-24 04:55:49 +03:00
Alexander
2d1482b400 minor fixes related to draft 2019-11-24 04:33:34 +03:00
Andrew Murray
e773980961 Updated URL [ci skip] 2019-11-22 10:12:52 +11:00
Hugo van Kemenade
a949d7882e
Merge branch 'master' into rm-2.7 2019-11-20 10:26:55 +02:00
Andrew Murray
40f891dfd7 Added UnidentifiedImageError 2019-11-19 21:20:02 +11:00
Hugo
e5486b40f8 Merge remote-tracking branch 'upstream/master' into rm-2.7 2019-11-18 13:56:42 +02:00
Andrew Murray
29c0a2fa6e
Merge pull request #4197 from hugovk/rm-plugins-__version__
Remove deprecated __version__ from plugins
2019-11-18 22:07:54 +11:00
Hugo van Kemenade
f81c829e04
Update word order
Co-Authored-By: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2019-11-18 12:07:02 +02:00
Hugo
12a725988e Merge remote-tracking branch 'upstream/master' into rm-2.7 2019-11-16 17:10:10 +02:00
Hugo van Kemenade
3134e5cd47
Merge pull request #4105 from radarhere/ifd
IFDRational init cleanup
2019-11-13 20:30:35 +02:00
Hugo van Kemenade
54e57768ab
Merge pull request #4128 from radarhere/info
Copy info in Image.transform
2019-11-13 20:27:51 +02:00
Hugo van Kemenade
ce18064b20
Merge pull request #4171 from radarhere/gamma
Corrected DdsImagePlugin setting info gamma
2019-11-13 20:26:03 +02:00
Hugo
0c5895470c Remove deprecated __version__ from plugins 2019-11-05 17:01:03 +02:00
Hugo van Kemenade
24b8501d4b
Remove handling for pre-3.3 wide/narrow builds 2019-11-04 00:32:33 +02:00
Hugo van Kemenade
5006401d0b
Merge branch 'master' into rm-2.7 2019-11-03 22:48:26 +02:00
Jon Dufresne
4483642e45 Reuse deferred_error instead of _imaging_not_installed
deferred_error is a general implementation of _imaging_not_installed.
Can reuse rather than repeating the same logic.
2019-11-03 08:29:17 -08:00
Hugo
58e6d127b7 In Python 3, 'next' is renamed to '__next__' 2019-11-03 16:02:08 +02:00
Hugo van Kemenade
6060ed3d14
Merge pull request #4091 from nulano/libimagequant-features
Add libimagequant to features.py
2019-11-02 21:31:09 +02:00
Hugo
6f88d8dd6b black --target-version py35 2019-11-02 20:02:07 +02:00
Hugo
cc63f66575 Merge remote-tracking branch 'upstream/master' into rm-2.7 2019-11-01 13:22:56 +02:00
Hugo van Kemenade
2cf510e596
Improve handling of file resources (#3577)
Improve handling of file resources
2019-11-01 12:07:53 +02:00
Andrew Murray
b65fcb280a Copy info in transform 2019-10-30 22:14:01 +11:00
Andrew Murray
d716278d20 Corrected DdsImagePlugin setting info gamma 2019-10-30 22:13:06 +11:00
Andrew Murray
887a7e503c Only assign once 2019-10-30 22:10:38 +11:00
Andrew Murray
290189596e Removed redundant return 2019-10-30 22:10:38 +11:00
Andrew Murray
9b20276c45 Allow for arr KeyError 2019-10-30 07:23:08 +11:00
pwohlhart
47691906df
Better error messaging in PIL.image.fromarray 2019-10-29 10:12:03 -07:00
Andrew Murray
d9845c14c8 Lint fixes 2019-10-29 22:42:34 +11:00
Bei Pang
f53b86b673 Removed TypeError exception check in JpegImagePlugin; Updated comments in test 2019-10-28 09:48:37 -07:00
mixmastamyk
204803917c
Fix mismatched name, add explanation.
Mention why this information is not available in the EXIF tag specified for this purpose.
2019-10-27 23:36:33 -07:00
Bei Pang
a2b0269167 Added comment to ValueError 2019-10-27 07:50:30 +11:00
Bei Pang
bcc766e02d Use default DPI when exif provides invalid x_resolution 2019-10-27 07:50:30 +11:00
Hugo van Kemenade
40133cfc74
Merge branch 'master' into rm-2.7 2019-10-26 09:07:44 +03:00
Jon Dufresne
cae17eb927 Use more Pythonic super() instead of referencing parent class
https://rhettinger.wordpress.com/2011/05/26/super-considered-super/
2019-10-22 06:54:58 -07:00
Hugo
3dac6e2c62 Replace ImageShow.which() with stdlib
Co-Authored-By: Jon Dufresne <jon.dufresne@gmail.com>
2019-10-12 21:40:11 +03:00
Jon Dufresne
4cd4adddc3 Improve handling of file resources
Follow Python's file object semantics. User code is responsible for
closing resources (usually through a context manager) in a deterministic
way.

To achieve this, remove __del__ functions. These functions used to
closed open file handlers in an attempt to silence Python
ResourceWarnings. However, using __del__ has the following drawbacks:

- __del__ isn't called until the object's reference count reaches 0.
  Therefore, resource handlers remain open or in use longer than
  necessary.

- The __del__ method isn't guaranteed to execute on system exit. See the
  Python documentation:

  https://docs.python.org/3/reference/datamodel.html#object.__del__

  > It is not guaranteed that __del__() methods are called for objects
  > that still exist when the interpreter exits.

- Exceptions that occur inside __del__ are ignored instead of raised.
  This has the potential of hiding bugs. This is also in the Python
  documentation:

  > Warning: Due to the precarious circumstances under which __del__()
  > methods are invoked, exceptions that occur during their execution
  > are ignored, and a warning is printed to sys.stderr instead.

Instead, always close resource handlers when they are no longer in use.
This will close the file handler at a specified point in the user's code
and not wait until the interpreter chooses to. It is always guaranteed
to run. And, if an exception occurs while closing the file handler, the
bug will not be ignored.

Now, when code receives a ResourceWarning, it will highlight an area
that is mishandling resources. It should not simply be silenced, but
fixed by closing resources with a context manager.

All warnings that were emitted during tests have been cleaned up. To
enable warnings, I passed the `-Wa` CLI option to Python. This exposed
some mishandling of resources in ImageFile.__init__() and
SpiderImagePlugin.loadImageSeries(), they too were fixed.
2019-10-12 08:27:17 -07:00
nulano
accbe58b5e add Python version to selftest, rename brief parameter 2019-10-12 15:40:12 +01:00
Hugo
3e24c5fea4 Replace isStringType(t) with isinstance(t, str)
Co-Authored-By: Jon Dufresne <jon.dufresne@gmail.com>
2019-10-08 17:26:52 +03:00
Hugo
e118de943d Remove redundant __ne__ method
Co-Authored-By: Jon Dufresne <jon.dufresne@gmail.com>
2019-10-08 17:26:36 +03:00
Hugo
3a34081db5 Simplify temporary directory cleanup
Co-Authored-By: Jon Dufresne <jon.dufresne@gmail.com>
2019-10-08 17:25:55 +03:00
Hugo
84e53e3757 Simplify using subprocess.DEVNULL
Co-Authored-By: Jon Dufresne <jon.dufresne@gmail.com>
2019-10-08 17:25:42 +03:00
Andrew Murray
6cd99fc3cf
Merge branch 'master' into rm-2.7 2019-10-08 18:57:27 +11:00
Jon Dufresne
64032061c0 Move several imports to the top-level of the file
This better follows PEP 8 style guide:

https://www.python.org/dev/peps/pep-0008/#imports

> Imports are always put at the top of the file, just after any module
> comments and docstrings, and before module globals and constants.

This also avoids duplicate import code within the same file.
2019-10-07 06:28:36 -07:00
Hugo
4382413bb4 Remove redundant bytearray 2019-10-07 16:23:43 +03:00
Hugo
865b17d5cf Remove Python 2-compatibility code 2019-10-07 16:23:22 +03:00
Andrew Murray
7e3156eb17 Updated IFDRational operators 2019-10-07 14:30:59 +03:00
Hugo
538d9e2e5d Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03:00
Hugo
af770a6c55 Drop support for EOL Python 2.7 2019-10-07 14:30:59 +03:00
Andrew Murray
732eb7223f
Merge branch 'master' into rm-deprecated-qt 2019-10-06 13:35:38 +11:00
Andrew Murray
6a83d5b239
Merge pull request #4114 from radarhere/tiff_size
Removed deprecated setting of TIFF image sizes
2019-10-05 02:33:08 +10:00
Hugo van Kemenade
0a8f029971
Merge pull request #4113 from radarhere/version
Removed outdated VERSION comment
2019-10-03 22:56:12 +03:00
Hugo van Kemenade
d479572158
Changed condition to use DEBUG as a boolean (#4112)
Changed condition to use DEBUG as a boolean
2019-10-03 15:38:46 +03:00
Andrew Murray
d6ae0a99a7 Removed deprecated setting of TIFF image sizes 2019-10-03 22:12:28 +10:00
Hugo van Kemenade
7821b34924
Merge branch 'master' into rm-deprecated-qt 2019-10-03 14:14:00 +03:00
Andrew Murray
3cd7d9e4a2 Removed outdated VERSION comment 2019-10-03 20:54:55 +10:00
Andrew Murray
f61af2fed0
Merge pull request #4107 from hugovk/rm-deprecated-PILLOW_VERSION
Remove deprecated PILLOW_VERSION
2019-10-03 20:52:48 +10:00
Andrew Murray
1e6eac40fc Changed condition to use DEBUG as a boolean 2019-10-03 20:23:49 +10:00
Andrew Murray
f92f429317
Merge pull request #1730 from radarhere/frombuffer_args
Changed default frombuffer raw decoder args
2019-10-02 19:25:46 +10:00
Andrew Murray
91306dfac5
Merge pull request #4009 from radarhere/tifftags
Corrected tag types
2019-10-02 19:18:56 +10:00
Andrew Murray
94a64ea09c 7.0.0.dev0 version bump 2019-10-02 06:42:14 +10:00
Hugo
f898ccbaf8 Remove deprecated PILLOW_VERSION 2019-10-01 14:43:15 +03:00
Andrew Murray
75602d12e1 6.2.0 version bump 2019-10-01 19:23:32 +10:00
Hugo
f0a87e25a4 Drop support for EOL PyQt4 and PySide 2019-09-30 17:58:31 +03:00
Andrew Murray
b9693a51c9
Merge pull request #4103 from radarhere/dimension
Raise error if TIFF dimension is a string
2019-09-30 21:26:53 +10:00
Andrew Murray
f228d0ccbf
Merge pull request #4102 from radarhere/decompression
Added decompression bomb checks
2019-09-30 20:31:05 +10:00
Andrew Murray
9a977b975c Raise error if dimension is a string 2019-09-30 18:48:10 +10:00
Andrew Murray
eed2bfc5b4 Added decompression bomb checks 2019-09-30 18:45:13 +10:00