Commit Graph

3446 Commits

Author SHA1 Message Date
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
hugovk
883858151d Simple test for 1104 2015-03-26 14:05:17 +02:00
Alex Clark
15727e2685 Merge pull request #1150 from hugovk/license
Move LICENSE from /docs to make it more explicit
2015-03-26 07:57:59 -04:00
hugovk
6e36d5304d Move LICENSE from docs to make it more explicit [CI skip] 2015-03-26 13:52:57 +02:00
Alex Clark
db94d48c4e Wording nit [ci skip] 2015-03-24 18:30:42 -04:00
Alex Clark
cbe38021ab On second thought [ci skip]
I don't like the bold afterall
2015-03-24 18:29:31 -04:00
Alex Clark
3c221887f8 Jazz up README [ci skip]
I've not liked the "plain" readme for the last few releases, so I've adjusted things hopefully for the better:

- Rename/add section headers
- Divide content into two sections
- Provide bulleted list with most important links e.g. "install"
2015-03-24 18:23:55 -04:00
Alex Clark
f471544c9f Fix manifest [ci skip] 2015-03-24 18:00:08 -04:00
Hugo
36081f2015 Update CHANGES.rst [CI skip] 2015-03-24 09:02:59 +02:00
Hugo
8480400bd9 Merge pull request #1145 from audreyr/pieslice-ref-docs
Improve reference docs for PIL.ImageDraw.Draw.pieslice()
2015-03-24 09:01:52 +02:00
Audrey Roy
967d39d1d6 Improve reference docs for PIL.ImageDraw.Draw.pieslice() 2015-03-23 21:16:53 -07: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
Hugo
d25a8d7e96 Merge pull request #1143 from hugovk/pr1123fixup
Fix TabError from PR #1123
2015-03-21 10:58:38 +02:00
hugovk
b17384cfca Tabs to spaces and other flake8 fixes 2015-03-21 10:32:26 +02:00
Hugo
f820c5184d Update CHANGES.rst [CI skip] 2015-03-21 10:16:55 +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
Alex Clark
d0e720929a Nits [ci skip] 2015-03-18 05:46:54 -04:00
Alex Clark
a37e022a0c Wheels updates [ci skip]
- No longer experimental
- No longer need --use-wheels
2015-03-18 05:39:01 -04:00
Alex Clark
b5475f2e1a Nits [ci skip]
- Mac OS X is now called just OS X
- Capitalize headers
2015-03-18 05:19:32 -04:00
Hugo
ba7cd1c95a Merge pull request #1134 from fahhem/patch-1
Make gifmaker work with the current getheader
2015-03-15 09:18:59 +02:00
Fahrzin Hemmati
ddf17df928 Make gifmaker work with the current getheader
GifImagePlugin.getheader was updated about 2 years ago and changed the API that gifmaker expects.
2015-03-14 02:41:14 -07:00
George Davaris
5a49375d4f Fix UnboundLocalError in ImageFile 2015-03-11 15:37:02 +00:00
Alex Clark
6272f36653 Merge pull request #1130 from radarhere/patch-1
Fixed typos in CHANGES.rst [ci skip]
2015-03-09 22:33:22 -04:00
Andrew Murray
419ed13bb7 Fixed typos in CHANGES.rst [ci skip] 2015-03-10 13:26:40 +11: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
wiredfool
85977bc371 Update CHANGES.rst [ci skip] 2015-03-08 18:30:24 -07:00
wiredfool
4566a4dcbe Merge pull request #1128 from hugovk/noise
Fix ImagingEffectNoise
2015-03-08 18:29:44 -07:00
Andrew Murray
fb3fe4b877 Added documentation for font_variant() [ci skip] 2015-03-07 18:38:17 +11:00
wiredfool
001772c564 Updated Changes.rst [ci skip] 2015-03-06 13:07:28 -08:00
wiredfool
6a296a45c1 Merge pull request #1126 from hugovk/if0
Remove unreachable code (if 0)
2015-03-06 13:06:43 -08:00
Hugo
44bb45d3b3 Add OS X build badge [CI skip]
We have OS X builds in another repo. Show the badge here too, to help spot OS X build breaks sooner (for example, if might pass on Linux).
2015-03-06 10:52:10 +02:00
hugovk
9bd38bfa06 Run test_effect_noise() on non-Windows, don't be too strict 2015-03-05 23:21:42 +02:00
hugovk
f1333617d5 Replace harcoded assumption of RAND_MAX with constant. It caused an infinite loop if RAND_MAX > 32767 2015-03-05 23:14:36 +02: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
514c55aa16 Test fix for supported 32bit RGBA .cur file
Some .cur file with alpha was loaded fully opaque with PIL. Fixed, and fixed the test to take that into account.
2015-03-05 10:55:32 +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