Commit Graph

150 Commits

Author SHA1 Message Date
Andrew Murray
c96cdb5e77 Consistent DPI rounding 2019-03-30 15:03:57 +11:00
Andrew Murray
4a5666f1f4 Added transparency for all PNG greyscale modes 2019-03-27 07:41:33 +11:00
Andrew Murray
ce9dd67540 Added I;16 PNG save 2019-03-12 17:28:42 +11:00
Andrew Murray
8ddcc1de52 Load EXIF from PNG where eXIf chunk is after first IDAT chunk 2019-03-11 21:20:18 +11:00
Andrew Murray
365d5e541a Added EXIF support 2019-03-11 21:19:36 +11: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
Hugo
d02e2b5392
Merge pull request #3558 from radarhere/png
Allow for unknown PNG chunks after image data
2019-02-03 11:57:21 +02: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
Andrew Murray
4e0a73b4fa Allow for unknown PNG chunks after image data 2019-01-08 07:21:25 +11: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
ea2a0e4654 Handle IDAT chunks after image end 2019-01-03 19:13:19 +11:00
Andrew Murray
97ae0c42b1 Detect whether mimetype is image/png or image/apng 2019-01-02 14:13:10 +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
Andrew Murray
22837c37e2 Read textual chunks located after IDAT chunks 2018-12-24 23:58:19 +11:00
Andrew Murray
b637b5f7a2 Close exclusive fp before discarding 2018-11-13 22:13:55 +11:00
Hugo
619e5fde8d Remove unused local variables 2018-10-24 22:29:01 +03:00
Andrew Murray
c2189235af Line too long 2018-07-02 19:26:02 +10:00
Daniel Plakhotich
65c7875ff7 TestFilePng: Fix test_save_l_transparency()
It now really tests the file after saving.
2018-06-14 12:46:35 +03:00
Andrew Murray
b4e6cdadac Added py3 variable to _util 2018-04-20 09:19:13 +10:00
Andrew Murray
b560f5b417 Changed Python version checks in tests to use helper 2018-04-19 19:40:56 +10:00
Hugo
ecc4c7fecc Remove unittest regex deprecation warnings 2018-04-14 21:54:40 +03:00
Andrew Murray
4a781d0013 Replaced MacOS with macOS 2018-03-19 19:38:17 +11:00
Andrew Murray
f22f1628eb At least two spaces before inline comment 2018-03-04 21:36:33 +11:00
Andrew Murray
2202196162 Flake8 blank line fixes 2018-03-04 21:36:33 +11:00
Eric Soroos
a96ac321d5 merge error 2017-12-20 11:45:52 +00:00
Eric Soroos
25d961238c Added sRGB and cHRM chunks to PngInfo, added tests for #2782 2017-12-20 11:35:11 +00:00
Eric Soroos
1ea128c8a7 refactor out get_chunks 2017-12-20 11:33:22 +00:00
Jon Dufresne
8844e2dd71 Make PngImagePlugin.add_text() zip argument type bool
Always used as a bool, but was previously defined as 0/1. Use modern
idiomatic Python by using the bool type for bool arguments.
2017-12-16 09:13:45 -08:00
Andrew Murray
97662294f0 Added context manager support 2017-10-07 23:18:23 +11:00
wiredfool
e71757aa6f Merge pull request #2634 from wiredfool/issue_2629
Fix for memory leaks in font handling
2017-09-04 11:23:57 +01:00
Eric Soroos
41b5121d6e refactor png leak test to use PillowLeakTestCase 2017-09-04 09:58:52 +00:00
Andrew Murray
9e843a2d9b Changed format of lambda calls 2017-09-01 21:05:40 +10:00
Andrew Murray
371933a597 Added tests 2017-09-01 20:36:51 +10:00
Andrew Murray
c10ad19a2b Changed file opening in tests to use with 2017-09-01 20:03:54 +10:00
Alexander
349e300d7b use getchannel where is possible 2017-08-09 02:36:07 +03:00
wiredfool
e3f1e9293d fixing the png leak test memory calculations 2017-06-27 21:20:46 +01:00
wiredfool
5a671830d8 Merge pull request #2541 from uploadcare/fix-truncated-png-loading
Fix truncated png loading
2017-06-21 12:23:15 +01:00
wiredfool
8eb1dcb7c5 test for truncated png memory leak #2541 2017-06-21 03:31:32 -07:00
Andrew Murray
e8cba27bb1 Changed assert checks to more specific versions 2017-06-03 14:04:54 +10:00
Andrew Murray
f0480de118 Restricted PNG encoderinfo chunks to valid values when saving 2017-01-21 16:57:03 +11:00
Andrew Murray
ded14572a1 Added more tests for PNG chunk ordering 2017-01-21 14:47:59 +11:00
Andrew Murray
361f579579 Moved iCCP chunk before PLTE chunk when saving as PNG 2017-01-21 13:32:22 +11:00
Hugo
48b72eac34 Merge pull request #2184 from jdufresne/isinstance
Replace type() equality checks with isinstance
2016-11-01 19:07:06 +02:00
Jon Dufresne
a33939f5c3 Remove unused, open files at top level of tests.
The data read from the file was unused. The files remained opened and
were never explicitly closed.

Fixes some instances of warnings during tests:

"ResourceWarning: unclosed file ..."
2016-11-01 06:34:17 -07:00
Jon Dufresne
e44bb42ae9 Replace type() equality checks with isinstance 2016-10-31 06:41:43 -07:00
Andrew Murray
4c28926da3 Fixed typos 2016-10-02 21:31:53 +11:00
Tim Graham
0c66b80a95 Fix "invalid escape sequence" warning in Python 3.6
http://bugs.python.org/issue27364
2016-09-27 19:26:57 -04:00
hugovk
2c4a1209f4 flake8 2016-08-04 09:40:12 +03:00
homm
1ba4e9e5ba remove end of file banner from all files 2016-07-10 14:11:28 +03:00
Alexander Karpinsky
639bdd3c02 Merge pull request #1991 from kkopachev/png-crc-error-ignore
Ability to skip crc checks for ancillary chunks
2016-06-30 17:25:04 +04:00
Konstantin Kopachev
5f2fe6083c
CR feedback: don't use lambda 2016-06-29 17:29:55 -07:00
Konstantin Kopachev
885297d21f
Fix python 3 bytes to string concat error 2016-06-29 14:44:29 -07:00
Konstantin Kopachev
c3b970f046
Ability to skip crc checks for ancillary chunks 2016-06-29 12:24:37 -07:00
homm
1a6c6b1250 tests for icc profile in png 2016-05-12 20:31:54 +03:00
wiredfool
b2800b57a7 spelling typos 2016-05-03 19:46:22 +01:00
Oliver Tonnhofer
0f8d66bc96 add failing test for #1838; extend tests for current transparency behavior 2016-04-19 10:21:48 +02:00
wiredfool
90378c8298 Fixing compatibility with the truncated images tests 2016-04-04 05:40:37 -07:00
wiredfool
77da73c90f Catch struct.errors when verifying png files, convert to SyntaxErrors, fixes #1755 2016-04-04 03:08:22 -07:00
Andrew Murray
309ab1fc3d Various Flake8 fixes 2015-07-03 16:22:56 +10:00
Andrew Murray
a06b59bd52 Added various tests 2015-07-03 15:03:25 +10:00
Justin Wilson
e33b5c6355 Added test to check that png with null tRNS value defaults to a zero transparency value. 2015-05-27 09:45:27 -06:00
Andrew Murray
ee34d6843b Further health fixes 2015-04-24 18:24:52 +10:00
Andrew Murray
76fec69eda Removed unnecessary lambdas 2015-04-24 16:02:39 +10:00
Andrew Murray
d1c182cadc Various Flake8 fixes 2015-04-24 09:26:52 +10:00
wiredfool
8c2a7502a4 Correct the name 2015-01-28 10:02:04 -08:00
wiredfool
05fe86654c Added _repr_png method for ipython display hooks 2015-01-28 09:35:31 -08:00
wiredfool
b73c4b9e8b Test change -- different representation for invalid compressed object 2014-12-28 22:50:03 -08:00
Hugo
5e676ea0bd Merge remote-tracking branch 'upstream/master' into flake8
Conflicts:
	Tests/bench_cffi_access.py
	Tests/test_file_palm.py
	Tests/test_format_hsv.py
	Tests/test_image_putdata.py
	Tests/test_locale.py
	Tests/test_mode_i16.py
2014-09-23 16:35:20 +03:00
wiredfool
af672b1d7e Fix for handling P + transparency -> RGBA conversions 2014-09-20 10:27:52 -07:00
hugovk
94da23ea3b Fix tests. test_trns_p() needed assert_image_similar() in place of assert_image_equal() 2014-09-14 20:00:13 +03:00
hugovk
1de128d6b6 Merge branch 'master' into flake8 2014-09-14 10:23:51 +03:00
hugovk
e1c33d3190 Replace lena with hopper 2014-09-04 12:09:52 +03:00
hugovk
1335006cd7 flake8 2014-08-28 14:44:19 +03:00
Fredrik Tolf
2687b5cb8d Test unicode preservation in text chunks. 2014-07-23 08:17:11 -07:00
Fredrik Tolf
823d377e47 Added tests for iTXt saving. 2014-07-23 07:27:51 -07:00
Fredrik Tolf
2b4d91ed53 Added iTXt tests. 2014-07-23 01:09:06 -07:00
hugovk
cf04a9a0d2 Remove unused tearDownModule 2014-07-07 20:03:50 +03:00
hugovk
78003ca473 Update paths to Tests/images/ instead of Images/ 2014-06-23 09:19:29 +03:00
hugovk
3ec505958e Convert old tests to use unittest 2014-06-10 12:10:47 +03:00
hugovk
c9a4272af6 Replace python-imaging with python-pillow (but yet not Coveralls) 2014-06-03 13:02:44 +03:00
wiredfool
0d453d9805 Added test for Palette transparency=0 2014-02-28 16:29:34 -08:00
wiredfool
598bd02650 Tightened up the tests 2014-01-21 20:50:54 -08:00
wiredfool
0492409def don't use bare asserts, don't mask file builtin with local 2014-01-20 13:34:48 -08:00
Bruno Renié
e1e64904c7 Cleanup handling of ICC profile, more extensive testing 2014-01-19 19:09:40 +01:00
Bruno Renié
0348fcac51 Fix crash on save when icc_profile is None 2014-01-19 16:40:39 +01:00
Alex Clark ☺
ad47ea5a52 Merge pull request #424 from wiredfool/trns-write-bydefault2
Save the transparency header by default for PNGs
2013-12-28 05:57:45 -08:00
wiredfool
d65a2c8018 Save the transparency header by default for PNGs 2013-11-26 15:06:26 -08:00
wiredfool
0356741a29 Now using the rgbT2rgba conversion for L+transparency to RGBA, dropping the palette hack 2013-11-26 13:04:10 -08:00
wiredfool
e12528fb62 dyslexic typo 2013-11-26 12:22:09 -08:00
nikmolnar
d030b4f48a Added a test for issue #421 2013-11-22 16:04:51 -08:00
Christoph Gohlke
fb80d5b267 Circumvent classification of pngtest_bad.png as malware 2013-09-27 16:55:19 -07:00
Vytis Banaitis
febfd1e124 Python3 fix. 2013-08-20 17:09:22 +03:00
Vytis Banaitis
dbf40a0124 Catch truncated zTXt errors. 2013-08-20 15:17:17 +03:00
David Schmidt
5303f0ea66 added tests to cover save of four different png transparencies 2013-03-26 11:24:07 +01:00
Oliver Tonnhofer
6537ba19c3 backport PIL's PNG/Zip improvements
- add new FASTOCTREE quantizer with alpha support
- make ZIP compress level and type configurable
- support reading/writing PNGs with paletted alpha

source 3637439d51
2013-03-11 20:33:04 +01:00
Brian Crowell
a7e3b2e47b py3k: The big push
There are two main issues fixed with this commit:

* bytes vs. str: All file, image, and palette data are now handled as
  bytes. A new _binary module consolidates the hacks needed to do this
  across Python versions. tostring/fromstring methods have been renamed to
  tobytes/frombytes, but the Python 2.6/2.7 versions alias them to the old
  names for compatibility. Users should move to tobytes/frombytes.

  One other potentially-breaking change is that text data in image files
  (such as tags, comments) are now explicitly handled with a specific
  character encoding in mind. This works well with the Unicode str in
  Python 3, but may trip up old code expecting a straight byte-for-byte
  translation to a Python string. This also required a change to Gohlke's
  tags tests (in Tests/test_file_png.py) to expect Unicode strings from
  the code.

* True div vs. floor div: Many division operations used the "/" operator
  to do floor division, which is now the "//" operator in Python 3. These
  were fixed.

As of this commit, on the first pass, I have one failing test (improper
handling of a slice object in a C module, test_imagepath.py) in Python 3,
and three that that I haven't tried running yet (test_imagegl,
test_imagegrab, and test_imageqt). I also haven't tested anything on
Windows. All but the three skipped tests run flawlessly against Pythons
2.6 and 2.7.
2013-01-10 08:46:56 -06:00
Brian Crowell
197885164b py3k: Backport Gohlke's tests to run on 2.6/2.7
Most of the differences are in tobytes/tostring naming and expected
behavior of the bytes() constructor. The latter was usually easy to fix
with the right bytes literal.

This is a good preview of what will have to happen in the Python 3 code.
2013-01-10 08:46:39 -06:00
Brian Crowell
ad784eb808 py3k: Import Christoph Gohlke's test suite
This is Christoph Gohlke's test suite from his personal PIL package found
at http://www.lfd.uci.edu/~gohlke/pythonlibs/.

This is just to bring it in as a separate commit. Future commits will align
it with Pillow.
2013-01-10 08:46:39 -06:00