Commit Graph

187 Commits

Author SHA1 Message Date
Tsung-Po Sun
324d934128 Remove spaces 2021-04-11 12:41:32 +10:00
Tsung-Po Sun
824d2fa4f3 Add test 2021-04-11 12:41:32 +10:00
Andrew Murray
92edc29439 Round down the radius in rounded_rectangle 2021-04-05 08:54:06 +10:00
Andrew Murray
6591297239 Increased use of assert_image_equal_tofile 2021-03-20 22:32:27 +11:00
Andrew Murray
9ce3eba7eb Only draw each pixel once 2021-03-08 19:54:03 +11:00
Andrew Murray
f5d49f4f61 Added rounded_rectangle method 2021-03-08 19:53:59 +11:00
Andrew Murray
c0ee869c2c Only draw each rectangle outline pixel once 2021-02-22 07:48:58 +11:00
Andrew Murray
a5c251029c Replaced various instances of assert_image_equal with assert_image_equal_tofile 2021-02-21 22:15:56 +11:00
Hugo van Kemenade
15c339470d
Merge pull request #4523 from xtsm/ellipse
Implemented another ellipse drawing algorithm
2020-10-11 18:04:34 +03:00
nulano
3fc1be06e6 add and fix tests for text anchors 2020-09-22 11:31:43 +02:00
Andrew Murray
9c22425881 Lint fix 2020-09-05 13:32:59 +10:00
Hugo van Kemenade
3dba4ee10a
Merge pull request #4846 from comhar/features/compute_polygon_coordinates 2020-09-04 23:28:43 +03:00
Hugo van Kemenade
e0eec1eb56 Merge branch 'master' into rm-3.5 2020-09-01 20:16:46 +03:00
Tommy C
b142560488 Rename b_circle and bounding_circle + accept ((x0, y0), r)
Summary of changes

- Rename `b_circle` and `bounding_circle`
-`bounding_circle` now accepts both formats below:
    - (x0, y0, r)
    - ((x0, y0), r)
2020-08-22 20:19:23 +01:00
Tommy C
df9329f9f0 Replace bbox with b_circle, kwargs with args + minor tweaks
Summary of changes:
 - `ImageDraw.regular_polygon` now accepts a bounding circle which
inscribes the polygon. A bounding circle is defined by a center point
(x0, y0) and a radius. A bounding box is no longer accepted.
 - All keyword args have been replaced with positional args.

Misc
- Test image file renaming, minor variable name changes
2020-08-20 20:46:11 +01:00
Tommy C
ac7d41545d Update regular_polygon args + arg checks
Summary of changes

- Allow positional args in `regular_polygon` method
- Allow multiple bounding box formats
    - (e.g. bbox = [(x0, y0), (x1, y1)] or [x0, y0, x1, y1])
- Check if bounding box is square
- Update var names
    - b_box => bbox
    - nb_sides => n_sides
2020-08-16 21:07:16 +01:00
Tommy C
0ed01dd964 Add ImageDraw.regular_polygon 2020-08-16 13:29:13 +01:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Hugo van Kemenade
10615a7da7 Upgrade Python syntax for 3.6+
Co-authored-by: nulano <nulano@nulano.eu>
2020-07-30 10:09:18 +03:00
Stanislau Tsitsianok
88651c334f
Try to fix CI 2020-06-29 23:58:58 +03:00
Stanislau Tsitsianok
7dedb1402f
Merge remote-tracking branch 'upstream/master' into ellipse 2020-06-29 23:31:25 +03:00
Stanislau Tsitsianok
5830a641cc
Added more tests 2020-06-29 23:31:04 +03:00
Stanislau Tsitsianok
9a9d3a050a
Fixed tests 2020-06-29 22:49:11 +03:00
Andrew Murray
b042483baa Replaced assert_image_similar with assert_image_similar_tofile 2020-06-23 19:17:41 +10:00
Andrew Murray
c1fe0b4e0c Use hypot function 2020-06-23 19:17:00 +10:00
Stanislau Tsitsianok
27109c9011
Merge remote-tracking branch 'upstream/master' into ellipse 2020-06-16 20:20:44 +03:00
Andrew Murray
eeb9e719e3 Fixed drawing a 1px high polygon 2020-06-07 12:07:13 +10:00
Andrew Murray
a5ef2b4499 Parametrized test 2020-06-04 07:56:14 +10:00
Stanislau Tsitsianok
305b61ed1c
Added test with various ellipse sizes 2020-05-08 23:54:17 +03:00
Andrew Murray
f5e9252b12 Fixed drawing a jointed line with a sequence of numeric values 2020-04-24 18:48:10 +10:00
Andrew Murray
5923f95f31 Adjusted symmetry test 2020-04-10 12:15:01 +10:00
Stanislau Tsitsianok
a491ed6889 fixed failing tests 2020-04-06 22:01:42 +10:00
Andrew Murray
17c10b0ca0 Fixed stroke on FreeType < 2.9 2020-02-24 22:49:33 +11:00
Jon Dufresne
4f185329f4 Streamline test skipping based on supported features
This adds a new test decorator: skip_unless_feature(). The argument is
the same as passed to features.check(). If the feature is not supported,
the test will be skipped.

This removes several kinds of boilerplate copied and pasted around tests
so test feature checking is handled and displayed more consistently.

Refs #4193
2020-02-18 13:07:01 -08:00
Andrew Murray
8e81e0dd0e Restored test 2020-02-16 13:44:34 +11:00
Hugo
9087599e60 Merge remote-tracking branch 'upstream/master' into pytest 2020-02-15 16:56:21 +02:00
Hugo van Kemenade
0e993c4740
Merge pull request #4334 from radarhere/outline_width
Allow explicit zero width to hide outline
2020-02-15 14:30:12 +02:00
Andrew Murray
919abe2555 Updated test 2020-02-15 21:17:26 +11:00
Hugo van Kemenade
c57e4b3a85
Merge pull request #4333 from radarhere/polygon
Only draw each polygon pixel once
2020-02-15 11:57:14 +02:00
Hugo
affade7595 Replace unittest with pytest 2020-02-13 12:15:05 +02:00
Hugo
a4bf9fa036 Convert most PillowTestCase methods to pytest 2020-02-02 12:26:01 +02:00
Andrew Murray
56f30ef792 Allow explicit zero width to hide outline 2020-01-08 21:55:15 +11:00
Andrew Murray
8e8f63d4a5 Only draw each polygon pixel once 2020-01-05 17:43:51 +11:00
Alexander
ac92836e81 Change default resize resampling filter 2019-12-07 18:08:19 +03:00
Andrew Murray
c0048ad7de Use context managers 2019-11-26 07:03:23 +11:00
Jon Dufresne
33dabf986f Import unittest from stdlib rather than helper.py
The unittest in helper.py has not offered an interesting abstraction
since dbe9f85c7d so import from the more
typical stdlib location.
2019-11-20 18:42:52 -08: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
Andrew Murray
b913fa6a53 Increased tolerance for stroke test comparison 2019-09-11 19:57:45 +10:00
Andrew Murray
da39d40342
Merge pull request #3978 from radarhere/stroke
Added text stroking
2019-09-06 19:14:49 +10:00
Hugo van Kemenade
cb1ebc024b
Merge pull request #4017 from radarhere/floodfill
Do not allow floodfill to extend into negative coordinates
2019-09-05 23:00:33 +03:00
Andrew Murray
23872c0645 Do not allow floodfill to extend into negative coordinates 2019-08-12 06:51:16 +10:00
Andrew Murray
8fff9a2444 Fixed arc drawing bug for a non-whole number of degrees 2019-08-12 06:50:58 +10:00
Andrew Murray
f93a5d0972 Added text stroking 2019-07-29 06:40:03 +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
Andrew Murray
e0cbfb2708 Consider I;16 pixel size when drawing 2019-06-23 07:33:55 +10:00
Hugo
5631718a8d Format with Black 2019-06-13 18:54:46 +03:00
Andrew Murray
21c7fd251c Fixed arc gaps 2019-05-03 23:37:37 +10:00
Jon Dufresne
4de5477b61 Remove unnecessary unittest.main() boilerplate from test files
With the introduction and use of pytest, it is simple and easy to
execute specific tests in isolation through documented command line
arguments. Either by specifying the module path or through the `-k
EXPRESSION` argument. There is no longer any need to provide the
boilerplate:

    if __name__ == '__main__':
        unittest.main()

To every test file. It is simply noise.

The pattern remains in test files that aren't named with `test_*` as
those files are not discovered and executed by pytest by default.
2019-02-03 10:10:16 -08: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
Hugo
d69ef6a529 Remove redundant parentheses 2018-10-24 22:29:56 +03:00
Andrew Murray
1e305380ae
Merge pull request #3094 from hugovk/add-width-to-shapes
Add line width parameter to rectangle and ellipse-based shapes
2018-09-29 23:21:03 +10:00
Andrew Murray
6dd0e48d9a Missing whitespace 2018-09-27 19:43:39 +10:00
Andrew Murray
b5af283732 Added support to floodfill for non-RGB colors 2018-09-26 22:22:17 +10:00
Andrew Murray
f3842460ba Added line joints 2018-09-16 21:29:09 +10:00
Andrew Murray
0411caba67 Catch ValueError when processing the edge of an image 2018-09-01 17:18:13 +10:00
Hugo
f70f952f85
Merge branch 'master' into add-width-to-shapes 2018-07-14 14:58:48 +03:00
Hugo
5d751572cc
Merge pull request #2922 from radarhere/fill_ink
Skip outline if the draw operation fills with the same colour
2018-07-02 22:19:35 +03:00
Hugo
d6e3ef85c2 Add width parameter to arc, chord, ellipse, pieslice 2018-07-02 11:26:42 +03:00
Hugo
9dedbff713 Add width parameter to rectangle 2018-07-02 11:21:30 +03:00
Andrew Murray
8d8d00f304 Changed ellipse point calculations to be more evenly distributed 2018-05-27 15:32:22 +10:00
Hugo
33592b4f73 No need to import sys 2018-05-17 23:21:47 +03:00
Hugo
90ab677d44 Re-enable test for PyPy 2018-05-17 22:18:18 +03:00
Andrew Murray
4d3339b703 Added tests 2018-01-05 11:26:24 +11:00
hugovk
5524d806b4 Failing test for #2783 2017-10-04 11:09:52 +00:00
Andrew Murray
5c2df30ac3 Removed ImageDraw.Draw del calls 2017-09-01 21:06:22 +10:00
Andrew Murray
9e843a2d9b Changed format of lambda calls 2017-09-01 21:05:40 +10:00
nediamond
d1b66e9dfd Added threshold parameter to ImageDraw.floodfill (#2599)
* added thresh option and test

* fixed up, test works and passes

* Update test_imagedraw.py

* Update test_imagedraw.py

* Update ImageDraw.py

* removed pypy skip decorator from thresh test

* Update ImageDraw.py
2017-07-01 10:37:02 +01:00
Hugo
08c72a1720 flake8 2017-05-16 10:33:38 +03:00
hugovk
206e316c0e Test limits of arc/ellipse's start and end 2017-05-15 22:58:51 +03:00
hugovk
f1631e0d05 Test drawing a rectangle bigger than the image 2017-05-15 21:44:28 +03:00
hugovk
5871b7a5ba Test drawing a wide "line" from one point to another just draws a single point 2017-05-15 21:32:54 +03:00
Hugo
ae9181f0a4 Test polygons in RGB and L modes 2017-05-15 18:24:12 +03:00
Hugo
e77c3b3eb2 Test ellipse in RGB and L modes 2017-05-15 18:23:00 +03:00
Hugo
d4a350cd79 Test chord in RGB and L modes 2017-05-15 18:04:33 +03:00
Hugo
3db1944762 Test drawing polygons with sloped and flat lines 2017-05-15 17:09:29 +03:00
Andrew Murray
37b293f593 Flake8 fixes 2017-04-20 21:14:23 +10:00
Andrew Murray
257bc8bd4f Added tests 2017-03-03 19:45:55 +11:00
wiredfool
a4ef743b0f Merge pull request #2220 from jdufresne/image-draw-dep
Remove long deprecated ImageDraw methods
2017-02-22 10:12:05 +00:00
hugovk
96dfd722c3 Test ImageDraw.Outline curve 2017-01-31 08:22:33 +02:00
hugovk
008431fe0e Test ImageDraw.Outline curve 2017-01-30 21:50:48 +02:00
Jon Dufresne
a5d6519d74 Remove long deprecated ImageDraw methods
Deprecated in 89ccf66ff7 since Sep 29,
2015, version 3.0.0.
2016-11-13 10:08:47 -08:00
homm
1ba4e9e5ba remove end of file banner from all files 2016-07-10 14:11:28 +03:00
Andrew Murray
3c2e374824 Added test 2016-06-09 22:28:29 +01:00
Andrew Murray
8f9b3a7372 Changed arcs, chords and pie slices to use floats 2015-12-09 00:28:52 +11:00
Andrew Murray
f0944438ab Removed FIXME from ImageDraw test 2015-12-08 00:03:38 +11:00
wiredfool
89ccf66ff7 Merge pull request #1343 from radarhere/deprecated
Removed deprecated code
2015-09-29 15:38:34 +01:00
Andrew Murray
71c95c8e5f Restored deprecated methods with errors instead 2015-09-19 21:36:19 +10:00
Andrew Murray
c6b13d294f Flake8 fixes 2015-08-25 22:27:18 +10:00
Andrew Murray
94ed100bb2 Removed ImageDraw methods deprecated in PIL 1.1.15 2015-07-13 17:41:26 +10:00
Andrew Murray
309ab1fc3d Various Flake8 fixes 2015-07-03 16:22:56 +10:00