Commit Graph

234 Commits

Author SHA1 Message Date
Andrew Murray
c13ccf13a1 Added missing whitespace 2018-03-06 19:53:07 +11:00
Andrew Murray
cca94054aa Changed assert statements to unittest calls 2018-01-17 22:01:37 +11:00
Andrew Murray
30b2ddd070 Removed duplicate imports 2018-01-04 15:40:46 +11:00
wiredfool
2611b2caa5 Merge pull request #2689 from radarhere/tests
Added tests
2017-09-04 11:15:28 +01:00
Andrew Murray
9e843a2d9b Changed format of lambda calls 2017-09-01 21:05:40 +10:00
Alexander
4d56db3a34 Fix wrong formula for subsampling=2 while JPEG saving 2017-08-27 20:03:36 +03:00
Vytis Banaitis
7c8e0e4457 Fix ZeroDivisionError when EXIF contains invalid DPI (0/0). 2017-08-09 16:16:14 +03:00
wiredfool
908fffdd2c Test for https://github.com/python-pillow/Pillow/issues/2628#issuecomment-315962612 2017-07-18 01:06:54 -07:00
Fran Barba
29c622dd3d Fixed typo biger > bigger 2017-06-29 11:21:19 +02:00
Fran Barba
a7d75c4b21 Applied Hugovk recommendations 2017-06-28 12:12:44 +02:00
Fran Barba
ebaa509d66 Adjust buffer size when icc_profile > MAXBLOCK (issue #148)
We were encountering some errors when saving specific JPEG images.
The error was shown in stderr as:
  IOError: encoder error -2 when writing image file

And on stdout it printed:
    Suspension not allowed here

The problem was the bufsize not contemplating the icc_profile block.
2017-06-28 12:11:33 +02:00
wiredfool
c3e041e9e6 Merge branch 'master' into rm-deprecated-fn 2017-06-13 13:32:38 +01:00
wiredfool
c16ba722f2 Merge pull request #2551 from jdufresne/keys
Remove unnecessary calls to dict.keys()
2017-06-13 13:12:48 +01:00
Andrew Murray
e8cba27bb1 Changed assert checks to more specific versions 2017-06-03 14:04:54 +10:00
Jon Dufresne
d244fbb299 Remove unnecessary calls to dict.keys()
iter(dict) is equivalent to iter(dict.keys()), so simply act on the dict
instead of adding the extra call.

Inspired by Lennart Regebro's PyCon 2017 presentation "Prehistoric
Patterns in Python". Available at:

https://www.youtube.com/watch?v=V5-JH23Vk0I
2017-05-28 09:55:38 -07:00
hugovk
e4d6223c94 Remove deprecated code due for removal in Pillow 4.2 (per PR #2010) 2017-05-27 23:20:03 +03:00
Hugo
a4bfe1a1d5 Test file with DPI in EXIF but not metadata, and XResolution is an int rather than tuple 2017-04-11 13:53:01 +03:00
wiredfool
0834e9491e Merge pull request #2330 from wiredfool/pr_2032
Close files after loading when possible.
2017-04-03 23:32:06 +01:00
Hugo
53df62647a DPI is a tuple (#2472)
* DPI is a tuple

* Some EXIF only contains an X resolution for DPI

* Refactor

* Test with no DPI in EXIF

* Handle EXIF with no DPI

* Created with: exiftool "-*resolution*"= photoshop-200dpi.jpg

* Test when not in EXIF, DPI==72,72

* Use X resolution for Y, default to 72,72 dpi

* Created with: exiftool -exif:ResolutionUnit=cm photoshop-200dpi.jpg

* Test for EXIF with dpcm instead of dpi

* Convert dpcm to dpi, and default to inches if unit unknown
2017-04-03 23:28:33 +01:00
wiredfool
db338ca19a open file check for windows, on jpeg where we don't mmap the file 2017-04-03 08:06:59 -07:00
Hugo
92acfca46f Test getting DPI from EXIF 2017-03-14 11:26:11 +02:00
Andrew Murray
798fde57ca Removed unused imports 2017-03-03 21:38:19 +11:00
wiredfool
7e2bd28a7c Fix for issue 2272, CMYK images miss the heuristic for the maxblock buffer scaling 2016-12-03 14:45:45 +00:00
wiredfool
4b57345683 Refactor random image 2016-12-03 14:45:05 +00: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
Andrew Murray
d3d29ab2e3 Use truth value when checking for optimize option on save 2016-09-25 21:20:54 +10:00
Andrew Murray
de6158f5f1 Read value when checking for JPEG progressive key 2016-09-23 20:32:21 +10:00
Andrew Murray
051a410859 Convert DPI to ints when saving as JPEG 2016-09-22 19:41:32 +10:00
wiredfool
e980ca7896 Merge pull request #2010 from uploadcare/jpeg-raise-on-alpha
Show warning when trying to save RGBA image as JPEG
2016-08-25 11:41:49 +01:00
homm
193c756139 return implicit RGBA to JPEG save, raise warning 2016-08-09 03:11:35 +03:00
homm
1ba4e9e5ba remove end of file banner from all files 2016-07-10 14:11:28 +03:00
homm
c1da18e0ad do not allow to save images discarding alpha channel 2016-07-03 05:40:34 +03:00
Konstantin Kopachev
c8f93c979c
Skip extra 0xff00 in jpeg 2016-06-22 13:36:23 -07:00
Stephen Arthur
7872501c5b Added test cases to exhibit issues with custom qtables 2016-05-22 17:54:03 -07:00
Stephen Arthur
5025bdd487 Valid range for baseline jpeg qtables 1 to 255, fixed overflow from using signed char instead of unsigned char. added test 2016-04-07 09:35:14 -07:00
Stephen Arthur
b38c32ed70 Valid range for baseline jpeg qtables 0 to 255, fixed issue from using signed char instead of unsigned char. added test 2016-04-06 18:47:51 -07:00
Andrew Murray
677b958a7f Health fixes 2016-04-01 21:49:30 +11:00
wiredfool
a6c1331fdd Rolling back exif support to pre-3.0 format 2016-01-01 04:14:24 -08:00
Andrew Murray
a83bcec169 Flake8 fixes 2015-12-31 07:27:27 +11:00
wiredfool
253bc038c5 Python 3.2, sigh 2015-12-30 00:45:48 +00:00
wiredfool
31428b7009 Py3 fixes 2015-12-29 23:56:47 +00:00
hugovk
d9c90bba91 Test passes for 2.9.0, fails for 3.0.0 2015-12-29 22:57:36 +00:00
homm
0f87b1f125 suppress and check warning during tests 2015-09-15 04:07:02 +03:00
wiredfool
07d95c3861 Added test for typeerror test for gpsexif 2015-09-10 05:32:11 -07:00
Andrew Murray
3a25b1cd9b Added test for _getexif TypeError 2015-07-29 23:38:26 +10:00
Andrew Murray
2a3a34d2ff Treat MPO with unknown header as base JPEG file 2015-07-19 22:56:04 +10:00
Andrew Murray
309ab1fc3d Various Flake8 fixes 2015-07-03 16:22:56 +10:00
Andrew Murray
ee34d6843b Further health fixes 2015-04-24 18:24:52 +10:00
Andrew Murray
d1c182cadc Various Flake8 fixes 2015-04-24 09:26:52 +10:00
wiredfool
1e040feb1b Adjust buffer size when quality=keep, fixes #148 (again) 2015-01-18 10:56:29 -08:00
Christoph Gohlke
2538fa9e0f Fix AssertionError in TestFileJpeg.test_save_cjpeg 2014-09-29 11:35:46 -07:00
wiredfool
306ad74324 qtables error handling tests 2014-09-24 15:46:16 -07:00
wiredfool
1f377c2ace Merge from master 2014-09-23 09:52:03 -07:00
hugovk
1de128d6b6 Merge branch 'master' into flake8 2014-09-14 10:23:51 +03:00
etienne
416d8e340e Fixed issue #857.
When saving a JPEG and specifying 'keep' for quality or subsampling,
if the source JPEG image is in grayscale mode, don't try to find the
subsampling of the source, because grayscale images don't have any
subsampling (it's only for color components).

For the moment the fix also ignores subsampling of CMYK JPEG because
currently Pillow doesn't support encoding JPEG in YCCK mode (and
subsampling doesn't make sense in CMYK, but Pillow permits saving CMYK
JPEG with subsampling, that's a bug). This fix pass those errors
silently, i.e. it doesn't raise an error when 'keep' is used but it's
not possible to keep the subsampling (because the image is grayscale
or CMYK). I think it's the proper behavior but I'm not sure.
2014-09-02 14:52:25 -07:00
hugovk
42610c0ecd flake8 2014-08-28 17:18:54 +03:00
hugovk
c2f0903627 Correct the correction: RelatedImageWidth=0x1001, RelatedImageLength=0x1002 2014-08-27 11:06:34 +03:00
hugovk
a428321bee flake8 2014-08-27 10:57:40 +03:00
hugovk
d866a29bd8 Correct duplicate EXIF tags: http://www.exiv2.org/tags.html 2014-08-27 10:46:34 +03:00
Eric W. Brown
53b7f6294b First steps toward MPO support.
Allows Pillow to distinguish between JPEGs and MPOs, and provides some
MPO metadata handling. Does not yet handle multiple frames.
2014-07-16 11:36:56 -04:00
hugovk
cf04a9a0d2 Remove unused tearDownModule 2014-07-07 20:03:50 +03:00
Michael Brown
8b365f542a Skip tests if external commands aren't found 2014-06-27 19:11:01 -04:00
Michael Brown
d283f77884 Tests for _save_netpbm, _save_cjpeg and load_djpeg 2014-06-27 19:07:20 -04:00
wiredfool
dfe7ff515f Additional jpeg qtables tests 2014-06-20 01:09:59 -07:00
wiredfool
fcd4c662bf Fixed JPEG qtables test 2014-06-20 00:41:58 -07:00
wiredfool
7dc4dcc9fd Merge from master 2014-06-20 00:34:32 -07: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
Chris Sinchok
70a50907c2 This patch allows a JPEG image to be saved with a specific qtables
value (in dictionary format).

Previously, this would throw a TypeError when checking if the qtables
value was actually a preset. By adding an isStringType check, we can
avoid this error.
2014-05-28 17:21:58 -05:00
hugovk
0c1c620e30 Add test for #647. Fails without fix. 2014-05-21 14:33:28 +03:00
hugovk
aed2646dc2 pep8/pyflakes 2014-05-21 14:32:24 +03:00
wiredfool
5a4808d2d2 test cleanup: don't mask file builtin, data is unused 2014-03-27 16:44:58 -07:00
wiredfool
c7af2bf5b0 Test for #577 2014-03-27 16:39:58 -07:00
Joaquín Cuenca Abela
96ca9ff6ff Another attempt to achieve python 3 compatibility. 2014-02-04 17:37:18 +01:00
Joaquín Cuenca Abela
97b23af7e5 Try to fix test_file_jpeg in Python3 2014-02-04 17:23:29 +01:00
Joaquín Cuenca Abela
a0af87e524 Make test_file_jpeg compatible with Python 3 2014-01-28 08:48:40 +01:00
Joaquín Cuenca Abela
bab068a337 Improve heuristic used when saving progressive and optimized JPEGs with high quality values. 2014-01-27 20:27:03 +01:00
Joaquín Cuenca Abela
c68044bf7f Fix IOError when saving progressive JPEGs.
when the jpeg encoder sees the flags optimize or progressive (or progression)
it will write the full image in one shot.

The bufsize needs to be big enough to hold the entire image. The current heuristic
is that the entire compressed image will fit in width * height bytes, but this
heuristic is only applied to save operations with the flag "optimize" and not to
save operations with the flag "progressive".

This patch fixes this oversight.

(Btw, it will probably be a good idea to have a loop that retries with a bigger
bufsize in case this guess is not big enough.)
2013-08-02 14:36:46 +02:00
wiredfool
37359369ce Code to ensure buffer space for exif write and jpeg_write_scanline calls, tests, corrected buffer length calculation 2013-05-14 22:29:31 -07:00
wiredfool
2a743c9527 JpegImagePlugin sets bufsize for optimized images 2013-03-22 22:27:12 -07:00
wiredfool
c6249a5b76 Remove irrelevant test 2013-03-14 15:45:44 -07:00
Mikhail Korobov
a71183dab5 better fix for #15 (with a test case now) 2013-02-26 17:12:11 +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