Commit Graph

849 Commits

Author SHA1 Message Date
Alex Clark
071df8d33d Some Flake 8 fixes 2015-04-01 15:38:18 -04:00
Alex Clark
ea65087a20 Merge pull request #1125 from artscoop/patch-1
Fix 32-bit BMP loading (RGBA or RGBX)
2015-04-01 15:23:32 -04:00
hugovk
2879819ce7 Style/health fixes 2015-04-01 16:47:01 +03:00
Hugo
4308872809 Merge pull request #1131 from mixcloud/gd-unbound-local-variable
Fix UnboundLocalError in ImageFile
2015-04-01 14:16:36 +03:00
Alex Clark
b9fb9449fb Merge pull request #1160 from radarhere/health
Further health fixes
2015-04-01 06:06:47 -04:00
Alex Clark
c91768f7bf Merge pull request #1117 from radarhere/master
Allow truetype() to search for extensions other than .ttf
2015-04-01 06:01:19 -04:00
George Davaris
68663ad352 Define t variable in a more appropriate place 2015-04-01 10:48:28 +01:00
Andrew Murray
bd3f036a56 Fixed many style problems in OleFileIO resulting from indentation 2015-04-01 17:48:26 +11:00
Andrew Murray
2834b78982 Removed or commented unused variables from OleFileIO 2015-04-01 17:22:44 +11:00
Andrew Murray
b75ee4c5b6 Added tests for font paths without extensions and for preferring ttf extensions 2015-04-01 15:26:00 +11:00
Andrew Murray
68d9860921 Changed list comprehension variable name to avoid redefinition 2015-04-01 12:45:08 +11:00
Andrew Murray
1199665033 Removed duplicate import from OleFileIO 2015-04-01 12:45:08 +11:00
Andrew Murray
1f5aeea463 Fixed incorrect import in FpxImagePlugin 2015-04-01 12:45:08 +11:00
Alex Clark
0925c4adbb Merge pull request #1152 from hugovk/1104
Fix: Cannot identify EPS images
2015-03-31 21:12:55 -04:00
Andrew Murray
440022e59f Added missing import in FpxImagePlugin 2015-04-01 11:21:15 +11:00
Andrew Murray
d88a7b778f Added missing self argument in PyAccess 2015-04-01 09:36:24 +11:00
Andrew Murray
75a760e5d6 Fixed unused imports and removed or commented unused variables from FpximagePlugin 2015-04-01 09:35:45 +11:00
Alex Clark
aaa26f316a Merge pull request #1151 from mfitzp/open-http-image
Add support for HTTP response objects to Image.open()
2015-03-28 07:21:15 -04:00
Alex Clark
860a1dedf1 Prep 2.8.0
No ci skip here because let's see CI run w/new version numbers. I'm starting to think (again) this bump should happen immediately after the release instead of right before the next? But I know @wiredfool had some objection to this at some point. As a compromise, maybe we could change to 2.9.0dev immediately following the release of 2.8.0.
2015-03-27 07:02:02 -04:00
Martin Fitzpatrick
735d342608 Add support for HTTP response objects to Image.open()
HTTP response objects returned from `urllib2.urlopen(url)` or
`requests.get(url, stream=True).raw` are 'file-like' but do not
support `.seek()` operations. As a result PIL is unable to
open them as images, requiring a wrap in `cStringIO` or `BytesIO`.

This commit adds this functionality to `Image.open()` by way of
an `.seek(0)` check and catch on exception
`AttributeError` or `io.UnsupportedOperation`. If this is caught
we attempt to wrap the object using `io.BytesIO` (which will
only work on buffer-file-like objects).

This allows opening of files using both `urllib2` and `requests`, e.g.

    Image.open(urllib2.urlopen(url))
    Image.open(requests.get(url, stream=True).raw)
2015-03-26 13:25:26 +01:00
hugovk
b885c04388 EPS parser: don't index blank lines 2015-03-26 14:06:54 +02:00
Andrew Murray
3e9e95b00a Changed truetype() to prefer .ttf extensions 2015-03-21 21:13:15 +11:00
Andrew Murray
84ec2af495 Allow truetype() to search for extensions other than .ttf 2015-03-21 21:13:15 +11:00
hugovk
b17384cfca Tabs to spaces and other flake8 fixes 2015-03-21 10:32:26 +02:00
Hugo
cabbc5d599 Merge pull request #1123 from radarhere/font_variant
Added copy method font_variant() and accessible properties to truetype()
2015-03-21 10:15:57 +02:00
George Davaris
5a49375d4f Fix UnboundLocalError in ImageFile 2015-03-11 15:37:02 +00:00
artscoop
80d6b29b77 Fix bug with bitmasks on a 1x1 RGBA file
Does not change testing on other files, but fixes a case which previously made PIL collapse.
The Bitmap was a 1x1 RGBA and provoked an exception in PIL, but every Image viewer can load it.
Fixed code with comparison of header size, compression type and loading type of masks and fixed it.
2015-03-10 02:08:23 +01:00
Andrew Murray
fb3fe4b877 Added documentation for font_variant() [ci skip] 2015-03-07 18:38:17 +11:00
hugovk
0b79c6e24a Remove unreachable code (if 0) 2015-03-05 21:07:16 +02:00
artscoop
8c003e9b3f And finally ?
Error happening in Python 3.x with P images:
in original code, palette data was created from a list of bytestrings. Changed to a full bytestring.
- `b"".join(list of bytestrings)` works in python 2.7 and 3.x
- `b"".join(bytestring)` works in python 2.7 but fails in python 3.x
No need to `join` anymore. Works in 3.x
2015-03-05 12:17:52 +01:00
artscoop
310684521a Update BmpImagePlugin.py
Fails on Python 3, tried some fixes before going the virtualenv3 route
2015-03-05 11:32:03 +01:00
artscoop
613d22fc75 Removed debug print
Again.
2015-03-05 10:44:54 +01:00
artscoop
9e3af5a161 Fix .cur 32/rgba, offsets etc.
Various fixes on code broken or not passing tests
2015-03-05 10:40:10 +01:00
artscoop
d7a78f3813 Fixing .cur special header offset
use offset provided
2015-03-05 09:02:09 +01:00
artscoop
82aa9011c9 Restored original error messages
I suspect the tests to check against an exact string when expecting an error
2015-03-05 08:47:34 +01:00
artscoop
c8fddb19f5 Update BmpImagePlugin.py
Getting bonkers but I need to know
2015-03-05 08:34:01 +01:00
artscoop
934651427d Use 1 and not P for basic 1bpp BMP
Readapted some original code.
2015-03-05 08:19:14 +01:00
artscoop
56439b728f Test with original code
...
2015-03-04 23:06:21 +01:00
artscoop
f953b98285 Try to fix tests
Choked on roundtrip, where a P;1 image was returned instead of a 1 image.
2015-03-04 22:40:04 +01:00
artscoop
7b657f6887 Fix for all good_tests
Fixed loading of all types of provided images (+rgba). Added edge case where the header is reported as 40 bytes long with BITFIELDS (they start past the 40 bytes of the header). Loading fails for RLE, but IIRC, they're unsupported so it's normal.
2015-03-04 22:05:32 +01:00
artscoop
c8551770eb Quickfix number 4
Until tests pass.
2015-03-04 19:55:08 +01:00
artscoop
497ddf9c68 Remember correct image offset if bitfields+palette
Use the provided image offset if there is palette data while the image is bitfielded.
2015-03-04 19:50:52 +01:00
artscoop
877c138e21 1bpp BMP fix
It appears that
{{{
  The handling of 1bpp bitmaps is a little complicated.
  When reading 1bpp bitmaps, the palette is ignored.
  1's are considered foreground, and they are considered black.
  0's are considered background, and they are considered white.
}}}
so the raw mode has to be `1;I`
2015-03-04 19:26:15 +01:00
artscoop
c0ce8d0ae8 Removed debug print
Debug print left in _save. Removed.
2015-03-04 18:29:28 +01:00
artscoop
456bd96565 Fix 32-bit BMP loading (RGBA or RGBX)
PIL choked on perfectly valid BMP files (32 bits with Alpha). It could not handle valid RGBA masks to determine the raw format.
To clarify things, I:
- Rewrote the `BmpImagePlugin.BmpImageFile` class to be far more readable
- Made error messages more explicit (e.g. say that RLE bitmaps are unsupported)
- Made a readable dict to contain BMP header information
- Kept the existing security checks
- Instead of reading palette info by chunks of 3/4 bytes, read the whole palette info at once and parse the data.
- Now works with BMPv4/5 with Alpha (and can be exported to alpha PNG for example)
- Tested load and save with RGB24, RGB8, RGB8L, RGB32 and RGBA32.
- Tested with one bogus file. File not accepted, as expected.

I wanted to test more BMP formats, but I could not find that many images.
But for all the types I tested, it worked flawlessly.
2015-03-04 18:15:56 +01:00
Andrew Murray
7a798f8724 Added copy method font_variant() and accessible properties to truetype() 2015-03-04 00:00:18 +11:00
Andrew Murray
f644adbb05 Fixed binary conversion bug, and added corresponding tests 2015-03-02 09:56:47 +11:00
amoibos
aeb1e61aa7 let python do the endian stuff 2015-03-02 00:16:13 +11:00
Robin Lewis
7fafd09bf5 Document filename parameter as deprecated in truetype() 2015-02-23 12:23:01 +00:00
Robin Lewis
066faeb211 Reference non-deprecated argument in truetype documentation 2015-02-23 12:00:52 +00:00