Do not represent scalar tags as 1-element tuples. Keep tag
type and count information in TiffTags.TAGS. Normalize data in
ImageFileDirectory.__setitem__: wrap and unwrap tuples as needed,
convert rationals to floats. (To ensure consistency, make the "tags"
attribute private.) Interpret byte data as a series of integers rather
than a bytearray (which should only map to the "undefined" type). On
Python3, if a str is assigned to an "undefined" tag, encode it as ASCII.
Note that a large number of tags have been removed from TiffTags.TAGS
because I do not have time to figure out the type and count of each of
them. They should be restored before this gets merged in.
This obviously breaks backwards compatibility in a lot of ways...
When saving a JPEG and specifying 'keep' for quality or subsampling,
if the source JPEG image is in grayscale mode, don't try to find the
subsampling of the source, because grayscale images don't have any
subsampling (it's only for color components).
For the moment the fix also ignores subsampling of CMYK JPEG because
currently Pillow doesn't support encoding JPEG in YCCK mode (and
subsampling doesn't make sense in CMYK, but Pillow permits saving CMYK
JPEG with subsampling, that's a bug). This fix pass those errors
silently, i.e. it doesn't raise an error when 'keep' is used but it's
not possible to keep the subsampling (because the image is grayscale
or CMYK). I think it's the proper behavior but I'm not sure.
1) Renamed USE_INLINE to PIL_USE_INLINE to avoid conflicts with
other headers/libraries.
2) Replace __WIN32__ and WIN32 with _WIN32
3) Don't define WIN32 when the compiler is MSVC but not on Windows
Why would you even...
4) Don't define strcasecmp if you're not even going to use it.
5) Don't include Windows.h with undefs for compilers newer than
1998 everywhere.
6) Don't surpress warnings for MSVC++ 4.0. People still using
MSVC++ 4.0 deserve it.
7) Don't include things that are already included in Windows.h
- add new FASTOCTREE quantizer with alpha support
- make ZIP compress level and type configurable
- support reading/writing PNGs with paletted alpha
source 3637439d51
This commit also renames some functions from "fromstring" and the like to
"frombytes". I'll probably need to come back later and update any
references to "string," here or in the docs.
I also noticed that encode allocates some data for certain codecs, but
never frees them. That would be a good bug to fix. I fixed the one where it
outright stole a pointer from Python.
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.
This updates several Python type definitions and uses to bring us closer
to Python 3 compatibility. This includes:
* Replacing staticforward and statichere with static. These were a hack for
old compilers and are not supported/needed anymore.
* Using Py_TYPE() instead of ob_type; ob_type is hidden in Py3.
* Replacing getattr with getters/setters. getattr is sort-of supported in
Py3, but Py_FindMethod is not. So we just use the newer
methods/getsetters mechanisms and start using PyType_Ready everywhere.
* Use PyVarObject_HEAD_INIT for types, since types are PyVarObject.
* Use PyMODINIT_FUNC for module initialization functions.
There are some tab/space issues in this commit. I'm set for spaces; the
source is a little schizo.