Commit Graph

147 Commits

Author SHA1 Message Date
Hugo van Kemenade
9f1f63a46b
Merge pull request #4862 from radarhere/subifds 2020-09-02 16:58:55 +03:00
Andrew Murray
186a4723c8 Added test for empty GPS IFD 2020-09-02 21:14:36 +10:00
Andrew Murray
298b7d0333 Update pre-commit 2020-08-31 18:50:15 +10:00
luphord
4bb35c57dd clarify comment
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2020-08-28 20:47:17 +10:00
luphord
ae5e0218e9 remove whitespace 2020-08-28 20:47:17 +10:00
luphord
1fd9ccfe3c test Exif self-equality 2020-08-28 20:47:16 +10:00
Andrew Murray
e96109b93c Added writing of subIFDs 2020-08-13 22:25:24 +10:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Kirill Kuzminykh
6d2fe429c2 Reformat code of `test_file_jpeg.py. 2020-06-22 12:20:57 +03:00
Andrew Murray
95ace8a39c
Merge branch 'master' into fix_jpeg_magic_number 2020-06-22 18:42:58 +10:00
nulano
a324f4a466 add version to features info block 2020-06-21 18:58:39 +10:00
Hugo van Kemenade
bcb8cbbf22
Merge pull request #4639 from radarhere/jfif
Write JFIF header when saving JPEG
2020-06-20 15:54:11 +03:00
Andrew Murray
65742cfc95 Renamed test 2020-06-20 09:57:51 +10:00
Andrew Murray
abbc890b20 Replaced OSError with more specific UnidentifiedImageError 2020-06-20 09:51:48 +10:00
Andrew Murray
3e9068a345 Decreased length of test image data 2020-06-20 09:48:55 +10:00
Kirill Kuzminykh
f99e0b824b Replaced primitive "magic number" inside of JpegImagePlugin._accept() function by more correct version. 2020-06-18 16:18:18 +03:00
Andrew Murray
ccac9e1a3a Changed to ImageFileDirectory_v2 2020-06-03 22:11:51 +10:00
Andrew Murray
696aa7972d Parametrized test 2020-05-26 07:15:20 +10:00
Andrew Murray
660894cd36 Write JFIF header when saving JPEG 2020-05-24 23:58:30 +10:00
Andrew Murray
df886ed386
Merge pull request #4290 from bluepython508/fix_djpeg_load_test
Fixes djpeg load test
2020-05-16 19:53:18 +10:00
Alexander
f15e4a8e06 truncate icclist instead of changing to None 2020-05-08 19:48:20 +03:00
Hugo
dda6145fce Since Python 3.3 IOError and WindowsError have been merged into OSError 2020-04-10 12:57:29 +03:00
Andrew Murray
e41cfade29 Add JPEG comment to info dictionary 2020-03-07 06:57:29 +11:00
Hugo
2cc6a9a974 Convert to use pytest 2020-03-02 16:31:08 +02:00
Hugo van Kemenade
3c995fd173
Merge pull request #4440 from radarhere/jpeg_quality
Allow saving of zero quality JPEG images
2020-02-25 12:02:53 +02:00
Hugo
699a9dadf1 Convert asserts 2020-02-22 18:07:04 +02:00
Andrew Murray
8482919a37 Converted most assert statements to pytest 2020-02-23 00:06:21 +11:00
Andrew Murray
a8c0794107 Allow saving of zero quality JPEG images 2020-02-21 22:05:44 +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
Jon Dufresne
98a2081a78 Move safe imports to the top of test files
These modules are safe to import and this better follows PEP 8.

From 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.
2020-02-17 10:49:27 -08:00
ben
a4721d374f Fixes djpeg load test
* Test fails with `libjpeg-turbo` and `libjpeg-progs` on Ubuntu 16.04
* Epsilon reported is 4.18...
2020-02-15 13:59:53 +11:00
Hugo van Kemenade
098406c304
Merge pull request #4390 from jdufresne/resource-warning
Fix ResourceWarning emitted during tests
2020-02-12 17:10:51 +02:00
Hugo
38bf862185 Replace PillowTestCase.assert_warning with pytest.warns 2020-02-03 11:11:32 +02:00
Hugo
a4bf9fa036 Convert most PillowTestCase methods to pytest 2020-02-02 12:26:01 +02:00
Jon Dufresne
2b84221edf Fix ResourceWarning emitted during tests
Appeared in the form:

    ResourceWarning: unclosed file <_io.BufferedReader name='Tests/images/invalid-exif-without-x-resolution.jpg'>

Enable all warnings to always display during tests to help catch these
warnings earlier.
2020-01-26 16:00:46 -08:00
Alexander
73171f5046 add test image 2020-01-20 17:25: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
2d7cfc4bbc
Merge pull request #4239 from radarhere/photoshop
Handle broken Photoshop data
2019-12-01 07:33:26 +11:00
Andrew Murray
e51be50549 Handle broken Photoshop data 2019-11-30 10:08:32 +11:00
Andrew Murray
c0048ad7de Use context managers 2019-11-26 07:03:23 +11:00
Bei Pang
f53b86b673 Removed TypeError exception check in JpegImagePlugin; Updated comments in test 2019-10-28 09:48:37 -07:00
Bei Pang
bcc766e02d Use default DPI when exif provides invalid x_resolution 2019-10-27 07:50:30 +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
nulano
cf1f8b0498 Tests.helper cleanup 2019-09-25 11:58:02 +02:00
Hugo van Kemenade
8e3c4e3658
Merge pull request #3965 from radarhere/truncated
Raise the same error if a truncated image is loaded a second time
2019-09-20 22:53:52 +03:00
Andrew Murray
023dcf27c2 Raise the same error if a truncated image is loaded a second time 2019-07-13 08:37:17 +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
Hugo
f87821e010 Format with Black 2019-06-13 18:54:11 +03:00
Andrew Murray
2274c2afc7 Fixed reading APP13 marker without Photoshop data 2019-04-05 20:02:45 +11:00
Andrew Murray
c96cdb5e77 Consistent DPI rounding 2019-03-30 15:03:57 +11:00