Commit Graph

56 Commits

Author SHA1 Message Date
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