Commit Graph

849 Commits

Author SHA1 Message Date
d-schmidt
54d4f5eb3c added option to load truncated image-files 2013-01-10 20:44:41 +01:00
d-schmidt
900f3a8ff7 Added possibility to save gifs with a custom palette when using color mode P 2013-01-10 20:34:58 +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
848579af9b py3k: Add Windows icon sanity test 2013-01-10 08:47:04 -06:00
Brian Crowell
276cc421f7 py3k: Add XPM read test
This test includes an XPM file with transparency.
2013-01-10 08:47:03 -06:00
Brian Crowell
d6a0dec15b py3k: Add TarIO test
Not too convinced of the size fix. While it works against my file, I'm not
sure someone would have accidentally been an index off and not noticed.
2013-01-10 08:47:03 -06:00
Brian Crowell
49b0d1563e py3k: Rewrite PdfImagePlugin into something more legible
After adding all the encode() calls, the PDF plugin (and a few others)
became much harder to read. This should be much easier on the eyes.
2013-01-10 08:47:02 -06:00
Brian Crowell
6765b8e026 py3k: Add .FLI sanity check, and fix palette bytes bug 2013-01-10 08:47:01 -06:00
Brian Crowell
4f7d784a71 py3k: Actually fix the EPS encoder
The EPS encoder wasn't part of Gohlke's test suite, so the previous "fixes"
there were only expected syntactic ones. This gives a cleaner fix to the
encoder.

The decoder doesn't work in round-trip due to a missing eps_decoder method
on the core module, but it's clear it worked at some point.
2013-01-10 08:47:00 -06:00
Brian Crowell
63be4a1334 py3k: Get rid of _ParserFile; io.BytesIO does its job 2013-01-10 08:46:59 -06:00
Brian Crowell
8035b1a76a py3k: FIX: TGA missing o8 declaration
Plus, TGA was eligible for a round-trip test in test_imagefile. It has one
now.
2013-01-10 08:46:59 -06:00
Brian Crowell
254f0cf674 py3k: FIX: Bad upside-down check in BmpImagePlugin 2013-01-10 08:46:58 -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
80c2fa60ae py3k: Sort by key, not cmp
Py3k only supports key because it's more efficient. Not even sure 2to3
checks for this.
2013-01-10 08:46:54 -06:00
Brian Crowell
af94e2d93d py3k: Map long type to int
int() is really now long() in py3k, but to avoid breaking 2.6/2.7, we leave
the integer types where they are and just map long to int in py3k.

Also, pretty proud of myself for finding an easy way of detecting py3k.
2013-01-10 08:46:54 -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
e2283c664b py3k: Integer long literals are no longer valid syntax 2013-01-10 08:46:52 -06:00
Brian Crowell
260c1fad14 py3k: Convert StringIO.StringIO to io.BytesIO
io.BytesIO is already in 2.6. Some of the more obvious bytes literals are
marked in this commit.
2013-01-10 08:46:51 -06:00
Brian Crowell
dda0e9a3ed py3k: Tkinter module is now tkinter 2013-01-10 08:46:51 -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
aeab3f5911 py3k: Import reduce function
reduce() is no longer a built-in function in py3k.
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
eed042fae5 py3k: __nonzero__ is now __bool__ 2013-01-10 08:46:44 -06:00
Brian Crowell
3a665a7835 py3k: Add true Unicode support to OleFileIO
The day has arrived when Python provides an official way to handle Unicode
strings.
2013-01-10 08:46:44 -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
e514912378 py3k: Rewrite dictionary support for Tiff ImageFileDictionary
This commit brings in the collections.MutableMapping mixin to provide full
dictionary support for ImageFileDictionary.
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
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
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
cgohlke
11a859e7d3 Make FLI image detection more stringent 2012-12-20 21:47:45 -08:00
Manuel Ebert
4e397a4d1c Radius was hardcoded to 2.
This will probably, some time in the future get fixed upstream in PIL. Maybe.
2012-12-06 16:19:55 -08:00
Tom Payne
e414c66070 Add Image.alpha_composite 2012-12-04 16:44:26 +01:00
tdesvenain
3eda40cb4c revert last commit, images rendered didn't match very well 2012-07-29 17:05:54 +02:00
tdesvenain
bc9455d059 Added a psd mode (mode 4, 16 bits). 2012-07-29 16:02:26 +02:00
tdesvenain
4ebe7fc459 Fix opening psd files with RGBA layers when A mode is not of type 65535
but 3.
Fixes issue https://github.com/python-imaging/Pillow/issues/3
2012-07-29 15:48:40 +02:00
Corey Richardson
f466def82d Better import of _imaging 2012-06-15 17:39:51 -03:00
Tom Gross
33e1ffe570 fixed reading of EPS pictures
found in: http://www.mail-archive.com/image-sig@python.org/msg03054.html
2012-04-26 17:00:22 +02: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