Commit Graph

386 Commits

Author SHA1 Message Date
Andrew Murray
afa4cadb23 Added width and height properties 2015-06-26 17:20:17 +10:00
Andrew Murray
b553ad7a70 Further fixes 2015-06-21 16:33:55 +10:00
Andrew Murray
c644bf9455 Do not import ImageQt until it is requested 2015-06-19 15:55:35 +10:00
Roman Inflianskas
2d706d74dc add functions to convert: Image <-> QImage; Image <-> QPixmap (see #897) 2015-06-18 11:21:14 +10:00
wiredfool
9abedaab1d Merge pull request #1248 from radarhere/health
Further health fixes
2015-06-16 11:54:03 -07:00
wiredfool
30631902d6 Merge pull request #1231 from radarhere/image_palette
Copy image when saving in GifImagePlugin
2015-06-16 11:49:41 -07:00
Andrew Murray
26bcc443d1 Specified exception types 2015-05-30 09:18:27 +10:00
Andrew Murray
a996033079 Fixed various typos 2015-05-29 14:59:54 +10:00
Andrew Murray
3c7e37d2d7 Replaced old-style classes 2015-05-27 00:07:21 +10:00
Andrew Murray
b1e8a68df8 When copying Image, copy ImagePalette as well 2015-05-14 09:57:56 +10:00
Hugo
f21b45c976 Merge pull request #1184 from darkfeline/add-doc
Clarify docstring about mask values [ci skip]
2015-05-05 19:29:04 +03:00
Andrew Murray
d1c182cadc Various Flake8 fixes 2015-04-24 09:26:52 +10:00
Allen Li
e8107e3bbb Remove wrong docstring about RGBA paste [ci skip]
Pasting RGBA images does preserve the alpha channel if the current image
has an alpha channel.
2015-04-10 23:25:15 -04:00
Allen Li
c6d410ff3b Correct description of alpha-composite [ci skip] 2015-04-10 23:24:30 -04:00
Allen Li
7674694185 Correct description of paste() behavior [ci skip] 2015-04-10 23:23:26 -04:00
Allen Li
bb01e845ea Clarify docstring about mask values [ci skip]
The behavior of paste() with regard to intermediate mask values was
unclear, so this commit clarifies how it works.
2015-04-08 16:03:09 -04:00
hugovk
66e86f325f Catch struct.error on invalid JPEG (#1163) 2015-04-02 08:29:18 +03: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
wiredfool
d80c27dc3f Merge pull request #1095 from hugovk/pickle_L_mode
Fix pickling L mode images with no palette
2015-01-30 11:39:50 -08:00
hugovk
0f89322216 When unpickling, only put palette if there is one 2015-01-30 14:04:35 +02: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
Mikhail Korobov
52cbd123a2 DOC fix "Write Your Own File Decoder" link in Image API docs 2015-01-07 04:12:37 +05:00
homm
806c06f49f use less expensive BICUBIC resampling 2014-12-04 03:30:39 +03:00
homm
43d5d06ce4 rename Image.ANTIALIAS to Image.LANCZOS 2014-11-28 01:41:56 +03:00
wiredfool
e16ee15f2c Merge pull request #997 from homm/replace-resize
Replace resize method
2014-11-27 10:26:48 -08:00
Hugo
0accf25947 Merge pull request #1021 from wiredfool/save-docs
Docs for Image.save [ci skip]
2014-11-20 08:03:15 +02:00
Hugo
3052d4909c Merge pull request #1020 from wiredfool/quantize
Docstring for Image.quantize. [ci skip]
2014-11-20 08:01:10 +02:00
Hugo
2676845e7e Merge pull request #1019 from wiredfool/load-docs
Docs for PyAccess, PixelAccess objects [ci skip]
2014-11-20 07:58:59 +02:00
wiredfool
962ced916d Image.save docs, rename fp, link to params [ci skip] 2014-11-19 15:35:26 -08:00
wiredfool
af8588f34e Docstring for Image.quantize. [ci skip] 2014-11-19 14:26:07 -08:00
wiredfool
ee6f150ef1 Docs for PyAccess, PixelAccess objects [ci skip] 2014-11-19 14:04:39 -08:00
wiredfool
d1f4633c7b Many links to mode concept anchor [ci skip] 2014-11-19 12:49:27 -08:00
wiredfool
b13a90441f Better docs explaining import _imaging failure [ci skip] 2014-11-19 11:42:26 -08:00
homm
f88878c20b reflect changes in documentation 2014-11-09 21:52:16 +03:00
homm
693aff7ee1 remove thumbnail fallback 2014-11-09 21:52:16 +03:00
homm
aba798af25 replace resize implementation 2014-11-09 21:52:16 +03:00
wiredfool
cfbe49f124 Merge pull request #994 from homm/add-transpose
Add transpose and cache aware rotation
2014-11-07 13:58:18 -08:00
homm
32079b1dcc make transpose part of public api 2014-11-07 03:37:12 +03:00
Hugo
8b7a989018 Fix "can can" typo
Closes #971.

[CI skip]
2014-10-25 11:07:34 +03:00
wiredfool
042b809f81 Revert incorrect doc change [ci skip] 2014-10-21 09:57:46 -07:00
Eric Soroos
ba27920838 Fix for regression in scipy 2014-10-04 23:19:30 +00:00
wiredfool
1f377c2ace Merge from master 2014-09-23 09:52:03 -07: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
Hugo
91588383e7 Merge pull request #904 from hugovk/hopper3
Replace Lena with Hopper (Part II) & Fix for handling P + transparency -> RGBA conversions
2014-09-20 23:31:59 +03:00
wiredfool
af672b1d7e Fix for handling P + transparency -> RGBA conversions 2014-09-20 10:27:52 -07:00
Jim Garrison
c85e0e915b Image.close() docstring: use correct "its" 2014-09-17 21:36:59 -07:00
hugovk
1de128d6b6 Merge branch 'master' into flake8 2014-09-14 10:23:51 +03:00
Andrew Murray
255a090e97 Avoid resize operation if image is already the correct size 2014-09-10 10:41:46 +10:00
hugovk
bcc5305125 Add access functions for ImagingEffectSpread with a test 2014-09-02 15:53:58 +03:00
hugovk
8c96d38ce9 Add access functions for ImagingEffectMandelbrot with a test 2014-09-02 15:14:00 +03:00
hugovk
860e67e1c4 Add access functions for ImagingEffectNoise with a test 2014-09-02 14:11:08 +03:00
hugovk
1335006cd7 flake8 2014-08-28 14:44:19 +03:00
Eric W. Brown
c97d1a5601 Updates to MPO handler based on review.
Took out the explicit reference to the MPO Plug-in in Image as it’s now
indirectly referenced via the JPEG Plug-in. Removed the direct MPO
Plug-in registration as it’s now shared with the JPEG Plug-in.
Commented on assertion.
2014-07-28 11:14:38 -04:00
Eric W. Brown
8101c2a313 Merge branch 'master' of https://github.com/python-pillow/Pillow 2014-07-25 10:08:18 -04:00
Eric W. Brown
dcd171c1b8 Minor refactoring per discussion and MPO docs. 2014-07-24 11:16:12 -04:00
wiredfool
625ff24358 Storage, packing and access for HSV format images 2014-07-22 16:09:22 -07:00
Eric W. Brown
d5909e4946 Basic MPO reading works, seek is partially there. 2014-07-22 13:31:51 -04:00
Eric W. Brown
5857053be4 Activated MPO detection.
Added MPO to the list to be checked. Removed the superfluous second os
import. Added OS X & Komodo work files to .gitignore.
2014-07-17 12:30:45 -04: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
Andrew Murray
1aee9bfdef Added class checking to __eq__ function 2014-07-05 23:16:14 +10:00
cgohlke
a5ae40c1b4 Fix AttributeError: class Image has no attribute 'DEBUG' 2014-06-24 22:53:23 -07:00
Hugo
0cd52412b1 Merge pull request #654 from wiredfool/cleanup
Thanks.
2014-06-24 12:16:13 +03:00
hugovk
46abe78b77 Use a custom subclass of RuntimeWarning for DecompressionBombWarning 2014-06-23 10:53:08 +03:00
hugovk
195453679a Merge branch 'master' into bomb
Conflicts:
	PIL/Image.py
2014-06-23 09:51:46 +03:00
Alex Clark
6a79d80374 Revert "Merge pull request #5 from hugovk/unittest1merge"
This reverts commit 0940f0b043, reversing
changes made to 07aa1a56bb.

Conflicts:
	.travis.yml
	test/helper.py
	test/test_imagedraw.py
2014-06-10 07:45:42 -04:00
Ben Williams
9415407b83 Fix a its/it's incorrect usage 2014-06-06 21:42:20 +01:00
wiredfool
618a79c1c6 Merge from master, pre-unittest conversion 2014-06-03 14:42:22 -07:00
François Boulogne
682ad75759 DOC: fix name in docstring 2014-06-03 16:34:23 -04:00
hugovk
d7ed249b29 Remove redundant commented code [CI skip] 2014-05-27 14:39:33 +03:00
hugovk
fd05e9c756 Test decompression bomb warnings 2014-05-27 12:40:52 +03:00
hugovk
b853696ad5 Remove stray debug print 2014-05-27 12:18:56 +03:00
hugovk
a0d8e5cb33 Set limit to to around a quarter gigabyte for a 24 bit (3 bpp) image 2014-05-27 12:10:10 +03:00
hugovk
29388f8395 Remove redundant comment [CI skip] 2014-05-26 16:26:42 +03:00
hugovk
35f1f4d8fa Change exception into a warning 2014-05-26 16:25:15 +03:00
hugovk
b7e5c27696 Remove temporary print 2014-05-24 17:52:48 +03:00
wiredfool
3b227d1a05 Merge from current master 2014-05-20 11:47:53 -07:00
wiredfool
6ab636fb5a Doc formatting fix 2014-05-20 09:27:56 -07:00
wiredfool
9a6e8f8e9d Noted previous default 2014-05-20 09:21:12 -07:00
wiredfool
8d4a77a939 merge from master 2014-05-20 08:58:09 -07:00
wiredfool
88d74883bb remove redundant transparency check 2014-05-19 14:12:43 -07:00
hugovk
0938145e57 Move to an elif clause of the if in line 778, as it's just another combination of mode,self.mode under the master transparency condition 2014-05-19 10:04:56 +03:00
hugovk
ca7608f1d5 Possible fix for #664 2014-05-17 20:36:17 +03:00
hugovk
ce2955ec71 Throw an exception when an opened image is larger than an arbitrary limit 2014-05-14 18:04:18 +03:00
hugovk
74514fa1f5 Some pep8 and pyflakes cleanup 2014-05-10 12:34:36 +03:00
hugovk
22a370afc2 Fix 12-year-old FIXME 2014-05-10 11:46:53 +03:00
wiredfool
54173d2c67 Cherry-pick of portions of patch a500ca1393, many shortcut ops added, no functional changes 2014-05-09 21:36:15 -07:00
hugovk
f1cc194955 Don't compare pyaccess in __eq__ 2014-04-26 21:23:45 +03:00
hugovk
2a6f2c5442 Add __eq__ and __ne__ to Image to be able to test image equality when pickling. Pickle more data. 2014-04-26 19:43:53 +03:00
hugovk
6c938b784b Remove duplication by calling __init__() (Suggested by @ulope: 6802c12f89 (commitcomment-6125853)) 2014-04-26 17:18:29 +03:00
hugovk
6802c12f89 Initialise object when unpickling 2014-04-25 09:01:16 +03:00
hugovk
a3edb45f08 pep8 2014-04-22 09:23:34 +03:00
hugovk
adfbe8323a Tests and partial implementation of pickling (#629) 2014-04-22 08:54:16 +03:00
wiredfool
8c6a4c0299 Docs changes for close/context manager 2014-04-17 21:53:49 -07:00
wiredfool
3d352329f4 Use the deferred error to provide a logical exception on access to a closed image 2014-04-08 23:43:13 -07:00
wiredfool
1256fb496e Merge from master 2014-04-08 23:22:40 -07:00
wiredfool
86d5c5c389 Have the tempfile use a suffix with a dot 2014-04-07 16:01:49 -07:00
wiredfool
844ed441de Add the suffix if it's not there, not if it is 2014-04-07 15:59:33 -07:00
Michal Čihař
07650be832 Fix variable name
Wrong variable name was used for transparency manipulations.
2014-04-07 17:36:36 +02:00
wiredfool
8adbaf8098 Better tests, fixes for leaking RGB->P transparency 2014-03-26 00:01:10 -07:00
wiredfool
8ea903ec59 Transparency conversion for L, RGP and P images, fixes #510 2014-03-25 23:34:41 -07:00
wiredfool
abebac25cc Sane quantize defaults for RGBA->P, fixes #544 2014-03-25 21:42:40 -07:00
Lars Buitinck
61975dd8ad more detailed error messages from Image.py 2014-03-24 17:49:19 +01:00
wiredfool
196a48b4fd added context manager support 2014-03-17 13:17:34 -07:00
Alex Clark
0e9f4c6c60 Merge branch 'dschmidt_palette_513' of https://github.com/wiredfool/Pillow into wiredfool-dschmidt_palette_513 2014-03-17 09:48:24 -04:00
wiredfool
1e331e3e6a Removed tempfile.mktemp, fixes CVE-2014-1932 CVE-2014-1933, debian bug #737059 2014-03-14 15:56:41 -07:00
wiredfool
f8ce951a2d Merge Changes from master 2014-03-04 22:41:36 -08:00
David Schmidt
6457eed2cb overwrite redundant Image palette with new ImageCore Palette after quantize, fixes #513 2014-03-04 21:44:32 -08:00
David Schmidt
37f4aea0d0 fixes #529
doc fix
2014-02-25 09:56:49 +01:00
wiredfool
288a563d1a merge from master 2014-01-31 13:45:31 -08:00
David Schmidt
af11b908cf Update Image.py
docs update/fixes
2014-01-10 18:27:43 +01:00
wiredfool
8a69f6caa0 use cffi by default in pypy, not in c-python 2014-01-06 22:08:14 -08:00
wiredfool
32f4097d1e Fixes putalpha tests
Make sure we clear the pyaccess object each time we reset the self.im
object
2014-01-05 22:18:42 -08:00
wiredfool
663f881b21 all original tests pass 2014-01-05 21:07:56 -08:00
wiredfool
5efe737f6f Cffi pixel access object, #248 2014-01-05 10:41:25 -08:00
Alex Clark ☺
ae7edfa58d Merge pull request #441 from wiredfool/lut
Image.point fixes for numpy.array and docs
2013-12-28 06:08:08 -08:00
Alex Clark ☺
d48f301d57 Merge pull request #423 from wiredfool/trns-png
Support for PNG tRNS header when converting from RGB->RGBA
2013-12-28 05:56:03 -08:00
wiredfool
4791d156f1 Comments/Docs, fixes #440 2013-12-10 16:05:05 -08:00
wiredfool
d05b5d9060 Restore numpy.array as valid lookup tables 2013-12-10 15:47:26 -08:00
Alex Clark ☺
eebb8c2a97 Merge pull request #408 from wiredfool/convert_doc
Image.convert mode 1 documentation update.
2013-11-29 15:15:23 -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
c546c5a4c0 Added conversion for RGB+Transparency to RGBA that adds an alpha mask corresponding to the transparency value, fixes #421 2013-11-26 12:24:19 -08:00
wiredfool
18ced74c06 Image.convert mode 1 documentation update. Fixes #407 2013-11-12 22:42:06 -08:00
David Schmidt
06301c9eba don't create a new palette on Image._new if one already exists (i.e. after im.copy()) 2013-11-12 14:41:35 +01:00
Eric Soroos
175c572432 I;16 images are little endian, not native endian 2013-10-19 03:28:31 +00:00
Alex Clark ☺
55a0792815 Merge pull request #380 from wiredfool/lcms2
LCMS1 replaced with LCMS2
2013-10-16 09:09:15 -07:00
wiredfool
ace78d0734 Lab is Uint, Int, Int. Tests failing 2013-10-11 23:31:47 -07:00
Stephen Johnson
b533aa665e Fix many formatting mistakes in PIL.Image's docstrings 2013-10-11 22:18:40 -07:00
wiredfool
1c3932e89f Added LAB mode, core dumped 2013-10-10 23:27:34 -07:00
wiredfool
10214bc6c4 Premultiply RGBA images prior to transform and resize and undo after 2013-10-04 13:25:32 -07:00
Christoph Gohlke
9bff0b14e0 Add numpy array interface support for 16 and 32 bit integer modes 2013-09-29 19:30:43 -07:00
Alex Clark ☺
e5279a284b Merge pull request #325 from manisandro/bytearray
Fix bytes which should be bytearray
2013-08-29 02:14:49 -07:00
Sandro Mani
1c4734b6bb Make bytePalette read-only buffer 2013-08-28 20:44:27 +02:00
Sandro Mani
4be146cf27 Fix bytes which should be bytearray 2013-08-28 20:18:13 +02:00
wiredfool
e3e0638a5f Fail fast if there's an import error on _imaging 2013-07-23 10:17:15 -07:00
Freek Dijkstra
d24a419299 Warnings if imaging library has wrong UCS support.
Raise exceptions for unknown errors.
2013-07-23 10:44:27 +02:00
Felipe Reyes
15eac684c4
Moved Image module docs from comments to docstrings 2013-07-09 15:12:28 -04:00
Felipe Reyes
25b6371b75
Moved PIL.Image.Image docs from comments to docstrings 2013-07-09 10:32:14 -04:00
Alex Clark
f56facb0c1 Clean up 2013-06-30 15:21:37 -04:00
Alex Clark
fd29e707e9 Apply @Arfrever patch, fixes #258 2013-06-30 07:04:42 -04:00
Alex Clark ☺
a9fd1f4a94 Merge pull request #225 from wiredfool/pr224
Fix Image.fromarray with NumPy arrays: Supersedes PR #224
2013-05-23 05:51:58 -07:00
wiredfool
587b9a79d8 ducktype the array_interface obj to see if it provides tobytes or tostring 2013-05-21 21:04:22 -07:00
Matt Davis
1082173030 Fix Image.fromarray with NumPy arrays
Image.fromarray attempts to call a method called `tobytes()` on the passed in object, but NumPy arrays don't have a `tobytes()` method, they have a `tostring()` method. (See http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.tostring.html).

I think this was changed accidentally in a Python 3 compatibility update in which this call was confused with the `tobytes` and `frombytes` methods of Image objects.
2013-05-21 18:35:11 -03:00
wiredfool
026f6bb61e namespaced operation works when installed as a zipped egg using 'sudo python[3] setup.py easy_install -l --zip-ok .' 2013-04-15 10:57:37 -07:00
wiredfool
b0fffd24a4 Merge branch 'master' of https://github.com/python-imaging/Pillow into namespaced 2013-04-09 12:08:13 -07:00
David Schmidt
836e3e05d8 create a palette before converting transparent L-Mode to RGBA
fixes #154
2013-04-09 13:21:38 +02:00
wiredfool
088c752e40 basic sanity check that the version of the _imaging.c and Image.py files are the same 2013-04-08 21:43:15 -07:00
wiredfool
7f698a6fc5 PIL imports work in python3/Ubuntu 2013-04-08 20:55:06 -07:00
wiredfool
c774f9ab4c merged pull request #88 to master, resolved conflicts 2013-04-08 20:31:28 -07:00
Oliver Tonnhofer
2d478fe82a fixed check for str with Python 3 2013-03-12 21:29:46 +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
Oliver Tonnhofer
c60bb09fcd Revert "Added support for PNG images with transparency palette"
This reverts commit 5baa1ac1b8.
2013-03-11 19:02:54 +01:00
Oliver Tonnhofer
1db3f9d53f Revert "Fix KeyError in Tests/test_file_xpm.py"
This reverts commit b29326b175.
2013-03-11 19:02:44 +01:00
Alex Clark
33f42c7fbd Revert "Use relative import for _imaging"
This reverts commit aff6eccec5.
2013-03-08 18:38:26 -05:00
Alex Clark
fd81ee9336 Fix imports 2013-03-08 17:39:50 -05:00
Christoph Gohlke
aff6eccec5 Use relative import for _imaging 2013-03-08 13:30:41 -08:00
Alex Clark
b29326b175 Fix KeyError in Tests/test_file_xpm.py 2013-03-07 15:20:52 -05:00
Alex Clark
3020c16eaa Fix imports 2013-03-07 11:20:28 -05:00
Mikhail Korobov
c59c6609f3 Restore fromstring & tostring aliases in 3.x 2013-03-07 15:23:40 +06:00
Alex Clark ☺
001a1521cb Merge pull request #64 from kmike/master
Testing improvements and better Python 3.x support
2013-03-05 12:11:07 -08:00
Alex Clark ☺
d097fa068c Merge pull request #56 from cgohlke/patch-4
BUG: PIL Image array interface has the wrong size for YCbCr
2013-03-05 12:02:05 -08:00
Mikhail Korobov
aacb8097c3 better warning messages for fromstring/tostring 2013-02-26 16:19:35 +06:00
Christoph Gohlke
bb07471d2e BUG: PIL Image array interface has the wrong size for YCbCr 2013-02-13 19:52:32 -08:00
David Schmidt
5baa1ac1b8 Added support for PNG images with transparency palette 2013-02-01 17:52:22 +01:00
Brian J. Crowell
c952134e00 py3k: Issue warnings when using the old fromstring/tostring
...although, you have to turn on deprecation warnings specifically in order
to get them.
2013-01-10 08:47:05 -06: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
275a895952 py3k: Type coercion is gone
Types aren't automatically converted for operations for you.
2013-01-10 08:46:55 -06:00
Brian Crowell
31c454b925 py3k: 2to3's "idiom" filter
This is, I guess, a few things the Python devs were just fed up with.

* "while 1" is now "while True"
* Types are compared with isinstance instead of ==
* Sort a list in one go with sorted()

My own twist is to also replace type('') with str, type(()) with tuple,
type([]) with list, type(1) with int, and type(5000.0) with float.
2013-01-10 08:46:53 -06:00
Brian Crowell
48cf699fe6 py3k: Change apply() to unpacking syntax
apply() is no longer available in py3k.
2013-01-10 08:46:52 -06:00
Brian Crowell
fa348ee9fe py3k: __builtin__ module is now builtins 2013-01-10 08:46:50 -06:00
Brian Crowell
dfb1b144d8 py3k: Remove Image types import
For awhile now, str == type("") and so on. So we use the appropriate int,
str, basestring, or tuple type where applicable.
2013-01-10 08:46:49 -06:00
Brian Crowell
83ff0b3b31 py3k: Use relative imports
In py3k, imports are absolute unless using the "from . import" syntax.

This commit also solves a recursive import between Image, ImageColor, and
ImagePalette by delay-importing ImagePalette in Image.

I'm not too keen on this commit because the syntax is ugly. I might go back
and prefer the prettier "from PIL import".
2013-01-10 08:46:48 -06:00
Brian Crowell
abd215e457 py3k: Remove tuples in parameter lists
Py3k no longer supports unpacking tuples in the parameters.
2013-01-10 08:46:47 -06:00
Brian Crowell
5076c35cc5 py3k: print is a function
Seriously, if you didn't know that, you've been in a freaking cave, man.
2013-01-10 08:46:46 -06:00
Brian Crowell
da1d715b8e py3k: Use isinstance for numbers and sequences
operator.isNumberType() and .isSequenceType() go away in py3k.
2013-01-10 08:46:45 -06:00
Brian Crowell
fc035814bd py3k: map and filter to list comprehensions
What's really going on is that map() and filter() return iterators in py3k.
I've just gone ahead and turned them all into list comprehensions, because
I find them much easier to read.
2013-01-10 08:46:43 -06:00
Brian Crowell
09f1081c95 py3k: Fix up uses of dictionary views, ranges, and has_key()
y.has_key(x) is gone (use x in y), and keys(), values(), items(), and
range() all return views.

Some iterables needed to be packed into lists, either because the code
expected a list (such as "range(256) * 3") or because the original
collection was being modified (automatic global declarations).

The Tiff ImageFileDictionary is a special case and will be dealt with in
another commit.
2013-01-10 08:46:42 -06:00
Brian Crowell
b386ed14dd py3k: Remove callable() function
callable(c) is isinstance(x, collections.Callable) in py3k.
2013-01-10 08:46:41 -06:00
Brian Crowell
af5228896a py3k: Add module initialization and unicode/bytes int/long thunks
This commit:

* Adds Python 3 module initialization functions. I split out the main init
  of each module into a static setup_module function.
* Adds a py3.h which unifies int/long in Python 3 and unicode/bytes in
  Python 2. _imagingft.c unfortunately looks a little kludgy after this
  because it was already using PyUnicode functions, and I had to mix and
  match there manually.

With this commit, the modules all build successfully under Python 3.

What this commit does NOT do is patch all of the uses of PyArg_ParseTuple
and Py_BuildValue, which all need to be checked for proper use of bytes
and unicode codes. It also does not let selftest.py run yet, because there
are probably hundreds of issues to fix in the Python code itself.
2013-01-10 08:46:37 -06:00
Brian Crowell
78575798d7 py3k: Update exception usage to modern syntax 2013-01-10 08:46:33 -06:00
Brian Crowell
37f22ebfcd py3k: Use string methods instead of string module
First, we go for the obvious stuff. The string module methods are gone in
3.0, so we translate them to the appropriate methods on the string class.
2013-01-10 08:42:49 -06:00
Tom Payne
e414c66070 Add Image.alpha_composite 2012-12-04 16:44:26 +01:00
Corey Richardson
f466def82d Better import of _imaging 2012-06-15 17:39:51 -03:00
Simon Law
5355fea83e Backport fix to split() after open() (regression in 1.1.7).
https://bitbucket.org/effbot/pil-2009-raclette/changeset/fb7ce579f5f9
2012-01-19 15:07:18 -05:00
Stéphane Klein
c144108396 Fix : resize need int values, append int conversion in thumbnail method 2011-07-20 15:49:37 +02:00
Alex Clark
9a640e3157 Forking PIL 2010-07-30 22:52:47 -04:00