Hugo
afa758eb33
Re-add deprecated PILLOW_VERSION to give projects more time to upgrade
2020-03-29 18:36:37 +03:00
Andrew Murray
ff6ca4159a
Prevent masking Image reduce method
2020-03-29 16:27:29 +11:00
orlnub123
84c33abaa0
Make key an argument
2020-02-22 12:30:10 +00:00
orlnub123
8f21d0ddf0
Improve rounding
2020-02-21 23:38:38 +00:00
orlnub123
2e716de63d
Floor the size
2020-02-16 21:26:17 +11:00
orlnub123
e226e4ed64
Don't upscale if the image is smaller than the size
2020-02-16 21:25:51 +11:00
orlnub123
e9ef1d236d
Fix size calculation of Image.thumbnail()
2020-02-16 21:25:51 +11:00
Alexander
54f3dc6006
Math functions return int in Python 3
2020-02-08 00:34:53 +03: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
34029e9af4
texts fixes
2019-12-30 03:23:30 +03: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
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
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
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
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
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
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
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
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
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
12a725988e
Merge remote-tracking branch 'upstream/master' into rm-2.7
2019-11-16 17:10:10 +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
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
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
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
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
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
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
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
f61af2fed0
Merge pull request #4107 from hugovk/rm-deprecated-PILLOW_VERSION
...
Remove deprecated PILLOW_VERSION
2019-10-03 20:52:48 +10:00
Hugo
f898ccbaf8
Remove deprecated PILLOW_VERSION
2019-10-01 14:43:15 +03:00
Andrew Murray
2f5e24da48
Removed warning
2019-09-25 18:52:53 +10:00
Andrew Murray
8f91eff078
Changed default frombuffer raw decoder args
2019-09-25 18:52:07 +10:00
Andrew Murray
595a8fd33c
Updated warning to specify time of change
2019-09-24 20:33:02 +10:00
Andrew Murray
82f4a0d8f2
Changed WindowsViewer format to PNG
2019-09-21 09:11:32 +10:00
Andrew Murray
0009646a41
Corrected comment [ci skip]
2019-09-16 21:06:13 +10:00
Andrew Murray
ef16cb8efe
ImageFileDirectory_v1 does not raise KeyError
2019-09-07 18:31:23 +10:00
Andrew Murray
f3ed44a566
Changed the Image getexif method to return a shared Exif instance
2019-08-23 06:13:20 +10:00
Andrew Murray
0b405c86be
Lazily use ImageFileDirectory_v1 values from Exif
2019-08-18 23:03:43 +10:00
Andrew Murray
75fe92fa88
Updated documentation [ci skip]
2019-08-16 19:16:06 +10:00
Jon Dufresne
d50445ff30
Introduce isort to automate import ordering and formatting
...
Similar to the recent adoption of Black. isort is a Python utility to
sort imports alphabetically and automatically separate into sections. By
using isort, contributors can quickly and automatically conform to the
projects style without thinking. Just let the tool do it.
Uses the configuration recommended by the Black to avoid conflicts of
style.
Rewrite TestImageQt.test_deprecated to no rely on import order.
2019-07-06 16:11:35 -07:00
Alexander Böhn
7b815a5f1d
Added an image.entropy()
method
...
This calculates the entropy for the image, based on the histogram.
Because this uses image histogram data directly, the existing C
function underpinning the `image.histogram()` method was abstracted
into a static function to parse extrema tuple arguments, and a new
C function was added to calculate image entropy, making use of the
new static extrema function.
The extrema-parsing function was written by @homm, based on the
macro abstraction I wrote, during the discussion of my first
entropy-method pull request: https://git.io/fhodS
The new `image.entropy()` method is based on `image.histogram()`,
and will accept the same arguments to calculate the histogram data
it will use to assess the entropy of the image.
The algorithm and methodology is based on existing Python code:
* https://git.io/fhmIU
... A test case in the `Tests/` directory, and doctest lines in
`selftest.py`, have both been added and checked.
Changes proposed in this pull request:
* Added “math.h” include to _imaging.c
* The addition of an `image.entropy()` method to the `Image`
Python class,
* The abstraction of the extrema-parsing logic of of the C
function `_histogram` into a static function, and
* The use of that static function in both the `_histogram` and
`_entropy` C functions.
* Minor documentation addenda in the docstrings for both the
`image.entropy()` and `image.histogram()` methods were also
added.
* Removed outdated boilerplate from testing code
* Removed unused “unittest” import
2019-06-26 19:15:47 +10:00
Hugo
cab7231e2a
Format with Black
2019-06-11 11:42:05 +03:00
Hugo
169455f924
Refactor and format with Black
2019-06-10 18:22:46 +03:00
Hugo
53a7e35004
Format with Black
2019-06-10 18:22:46 +03:00
Andrew Murray
a94bd13791
Changed string formatting
2019-06-06 21:36:38 +10:00
Andrew Murray
4fa3016d67
Changed string formatting
...
Co-Authored-By: Hugo <hugovk@users.noreply.github.com>
2019-06-06 21:36:38 +10:00
Andrew Murray
77630f000c
Updated resampling filter error messages
2019-06-06 21:36:38 +10:00
Hugo
169961649d
Merge pull request #3848 from radarhere/pa
...
Improved palette handling for LA and PA modes
2019-06-05 22:32:44 +03:00
Jon Dufresne
3f2cfb2027
Remove unnecessary numeric placeholders from format strings
...
Unnecessary since Python 2.7.
2019-05-26 07:07:32 -07:00
Andrew Murray
e9c0cf61f3
Fixed palette for LA and PA mode when pickling
2019-05-11 14:43:00 +10:00
Andrew Murray
691df96734
Fixed opening mmap image through Path on Windows
2019-05-04 15:00:49 +10:00
Andrew Murray
40bc46ff49
Moved ImageFile.Exif to Image.Exif
2019-04-01 20:03:02 +11:00
Hugo
4f8cfd536b
Merge pull request #3721 from radarhere/quantize
...
Update palette in quantize
2019-03-30 12:07:38 +02:00
Andrew Murray
dba38912fb
Allow putpalette for LA and PA
2019-03-29 23:13:50 +11:00
Hugo
a93bcdfe0c
Merge pull request #3724 from radarhere/readonly_save
...
Ensure image is mutable before saving
2019-03-28 11:53:33 +02:00
Hugo
e7c2828b4e
Merge pull request #3740 from radarhere/remap_palette
...
Corrected remap_palette documentation
2019-03-28 11:47:36 +02:00
Hugo
0572983104
Merge pull request #3726 from radarhere/pa
...
Promote P images to PA in putalpha
2019-03-28 11:44:52 +02:00
Hugo
adbe97594e
Merge pull request #3719 from radarhere/p_rgb_rgba
...
Allow RGB and RGBA values for new P images
2019-03-27 18:03:23 +02:00
Andrew Murray
4a5666f1f4
Added transparency for all PNG greyscale modes
2019-03-27 07:41:33 +11:00
Andrew Murray
81cfede546
Corrected remap_palette documentation [ci skip]
2019-03-23 09:36:59 +11:00
Andrew Murray
f61828acdc
Promote P images to PA in putalpha
2019-03-19 11:13:58 +11:00
Hugo
b8ea8814f0
Merge pull request #3683 from radarhere/exclusive
...
Only close original fp in __del__ and __exit__ if original fp is exclusive
2019-03-18 20:37:21 +02:00
Andrew Murray
9bdab56689
Replaced hasattr conditions with getattr and default
2019-03-18 09:15:37 +11:00
Andrew Murray
0b62337b6f
Ensure image is mutable before saving
2019-03-17 23:37:40 +11:00
Andrew Murray
fa8ecffff2
Corrected seek documentation
2019-03-17 00:00:10 +11:00
Andrew Murray
5b9c11b426
Update palette in quantize
2019-03-16 13:36:58 +11:00
Andrew Murray
6790c2e375
Allow RGB and RGBA values for new P images
2019-03-15 17:35:05 +11:00
Andrew Murray
22b0110f89
Only close original fp in __del__ and __exit__ if original fp is exclusive
2019-03-12 08:54:43 +11:00
Hugo
125a001b66
Merge pull request #3698 from radarhere/context
...
Only close exclusive fp on Image __exit__
2019-03-11 21:41:44 +02:00
Hugo
63f31ee380
Merge pull request #3699 from glasnt/topic/quantize-dither
...
Add option to set dither param on quantize
2019-03-11 12:18:32 +02:00
Andrew Murray
878244bf38
Fixed typo
2019-03-11 11:13:39 +11:00
Katie McLaughlin
0b63579f39
Add option to set dither param on quantize
...
Default the option to `1`, as per original setting
2019-03-09 10:36:13 +11:00
Andrew Murray
b29365e8a0
Updated list of Unix utilities used to show an image [ci skip]
2019-03-07 15:24:27 +11:00
Hugo
2edab165a1
Since #2527 , macOS saves to a temp PNG before showing
2019-03-06 15:57:58 +02:00
Andrew Murray
b1cc7df7ba
Only close exclusive fp on Image __exit__
2019-03-06 21:55:32 +11:00
Frédéric Chapoton
e514fbbbb1
use the already import io
...
instead of importing again from io (lgtm suggestion)
2019-03-02 21:19:57 +01:00
Andrew Murray
57807e9ce2
Merge pull request #3624 from hugovk/rm-VERSION
...
Remove deprecated VERSION
2019-03-02 11:47:59 +11:00
Hugo
d9f5f44799
Merge pull request #3632 from radarhere/thumbnail
...
Do not resize in Image.thumbnail if already the destination size
2019-02-27 23:37:20 +02:00
Andrew Murray
1162b4cf83
Do not resize if already the destination size
2019-02-13 19:26:37 +11:00
Jon Dufresne
dd1e7ccc4a
Slightly simplify Image.__eq__
...
Two identical types can be compared using the `is` operator. Object
identity is slightly faster than a string comparison as well.
2019-02-03 07:13:28 -08:00
Hugo
4d1a459fa7
Merge pull request #3574 from jdufresne/base-exc
...
Catch BaseException for resource cleanup handlers
2019-02-03 11:35:44 +02:00
Hugo
158d99b8b0
Remove deprecated VERSION
2019-01-30 15:46:14 +02:00
Jon Dufresne
51e95f6252
Catch BaseException for resource cleanup handlers
...
In the event of a SystemExit or KeyboardInterrupt, file resources should
still be cleaned up before re-raising the exception.
https://docs.python.org/3/library/exceptions.html#exception-hierarchy
2019-01-12 18:32:14 -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
Andrew Murray
71b64dcf73
Only close __fp if not fp
2019-01-04 12:29:23 +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
5edeca28b6
Corrected docstring
2018-12-28 07:14:44 +11:00
Hugo
69837baba2
Merge pull request #3490 from radarhere/open_files
...
Updated open files documentation
2018-12-13 21:14:22 +02: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
Andrew Murray
91f727051b
Updated open files documentation
2018-12-11 14:39:10 +11:00
Andrew Murray
ad26f53bf6
Updated comments
2018-12-05 18:19:00 +11:00
Hugo
c353225851
Prefer 'except Exception:' to bare 'except:'
2018-12-04 23:25:28 +02:00
Andrew Murray
47775f3d50
Resolve __fp when closing and deleting
2018-11-17 21:56:06 +11:00
Hugo
0b7910c7cd
flake8: E402 module level import not at top of file
2018-11-11 19:01:10 +02:00
Hugo
91da8ff31d
flake8: F401 imported but unused
2018-11-11 19:01:10 +02:00
Andrew Murray
e3220c0f4d
Changed capitalisation
2018-11-11 16:00:48 +11:00
Andrew Murray
747eccbfc2
Close exclusive fp on open exception
2018-11-09 11:35:08 +11:00
Andrew Murray
929f7397db
Line too long
2018-10-21 18:26:08 +11:00
Andrew Murray
6099ddeef9
Expected 1 blank line before a nested definition
2018-10-21 17:59:18 +11:00
Erich Seifert
9807f1ad56
Fixed documentation on bilevel conversion
...
The cutoff when converting an image to bilevel (mode "1") is 128. This should resolve issue #3394 .
2018-10-05 01:11:24 +02:00
Hugo
2fa54408d4
Merge pull request #3203 from radarhere/size
...
Changed Image size property to be read-only by default
2018-09-30 14:35:35 +03:00
Hugo
a0fda60662
Use snake_case
2018-09-30 15:34:33 +10:00
Andrew Murray
82d942c3d8
Added warnings if image file identification fails due to lack of support
2018-09-30 15:34:27 +10:00
Andrew Murray
0adeb82e98
Changed Image size property to be read-only by default
2018-09-30 13:45:18 +10:00