Removed trailing whitespace

This commit is contained in:
Andrew Murray 2015-10-11 21:24:35 +11:00
parent c4a16b6967
commit 6bd7e7f02d
30 changed files with 102 additions and 102 deletions

View File

@ -325,7 +325,7 @@ Changelog (Pillow)
- Adjust buffer size when quality=keep, fixes #148 (again) - Adjust buffer size when quality=keep, fixes #148 (again)
[wiredfool] [wiredfool]
- Fix for corrupted bitmaps embedded in truetype fonts. #1072 - Fix for corrupted bitmaps embedded in truetype fonts. #1072
[jackyyf, wiredfool] [jackyyf, wiredfool]
2.7.0 (2015-01-01) 2.7.0 (2015-01-01)
@ -412,7 +412,7 @@ Changelog (Pillow)
2.6.2 (2015-01-01) 2.6.2 (2015-01-01)
------------------ ------------------
- Fix CVE-2014-9601, potential PNG decompression DOS #1060 - Fix CVE-2014-9601, potential PNG decompression DOS #1060
[wiredfool] [wiredfool]
- Fix Regression in PyPy 2.4 in streamio #958 - Fix Regression in PyPy 2.4 in streamio #958
@ -1081,7 +1081,7 @@ Changelog (Pillow)
.. Note:: Special thanks to Christoph Gohlke and Eric Soroos for assisting with a pre-PyCon 2013 release! .. Note:: Special thanks to Christoph Gohlke and Eric Soroos for assisting with a pre-PyCon 2013 release!
- Many other bug fixes and enhancements by many other people. - Many other bug fixes and enhancements by many other people.
- Add Python 3 support. (Pillow >= 2.0.0 supports Python 2.6, 2.7, 3.2, 3.3. Pillow < 2.0.0 supports Python 2.4, 2.5, 2.6, 2.7.) - Add Python 3 support. (Pillow >= 2.0.0 supports Python 2.6, 2.7, 3.2, 3.3. Pillow < 2.0.0 supports Python 2.4, 2.5, 2.6, 2.7.)
[fluggo] [fluggo]

View File

@ -2269,7 +2269,7 @@ def open(fp, mode="r"):
return im return im
except (SyntaxError, IndexError, TypeError, struct.error): except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image # Leave disabled by default, spams the logs with image
# opening failures that are entirely expected. # opening failures that are entirely expected.
#logger.debug("", exc_info=True) #logger.debug("", exc_info=True)
continue continue
return None return None

View File

@ -42,8 +42,8 @@ Released as needed for security, installation or critical bug fixes.
``` ```
* [ ] In compliance with https://www.python.org/dev/peps/pep-0440/, update version identifier in: * [ ] In compliance with https://www.python.org/dev/peps/pep-0440/, update version identifier in:
``` ```
PIL/__init__.py PIL/__init__.py
setup.py setup.py
_imaging.c _imaging.c
appveyor.yml appveyor.yml
``` ```

View File

@ -144,7 +144,7 @@ level of support for it is arguably not important.</p>
<tr> <tr>
<td class=q>q/pal8rletrns.bmp</td> <td class=q>q/pal8rletrns.bmp</td>
<td>3</td> <td>3</td>
<td class=b><img src="pal8rletrns.png"><br> <td class=b><img src="pal8rletrns.png"><br>
or<br><img src="pal8rletrns-0.png"><br> or<br><img src="pal8rletrns-0.png"><br>
or<br><img src="pal8rletrns-b.png"></td> or<br><img src="pal8rletrns-b.png"></td>
<td class=b><img src="../q/pal8rletrns.bmp"></td> <td class=b><img src="../q/pal8rletrns.bmp"></td>

View File

@ -251,7 +251,7 @@ class TestFileTiff(PillowTestCase):
{256: (55,), 257: (43,), 258: (8, 8, 8, 8), 259: (1,), {256: (55,), 257: (43,), 258: (8, 8, 8, 8), 259: (1,),
262: (2,), 296: (2,), 273: (8,), 338: (1,), 277: (4,), 262: (2,), 296: (2,), 273: (8,), 338: (1,), 277: (4,),
279: (9460,), 282: ((720000, 10000),), 279: (9460,), 282: ((720000, 10000),),
283: ((720000, 10000),), 284: (1,)}) 283: ((720000, 10000),), 284: (1,)})
def test__delitem__(self): def test__delitem__(self):
filename = "Tests/images/pil136.tiff" filename = "Tests/images/pil136.tiff"

View File

@ -395,8 +395,8 @@ getlist(PyObject* arg, int* length, const char* wrong_length, int type)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
op = PySequence_Fast_GET_ITEM(seq, i); op = PySequence_Fast_GET_ITEM(seq, i);
// DRY, branch prediction is going to work _really_ well // DRY, branch prediction is going to work _really_ well
// on this switch. And 3 fewer loops to copy/paste. // on this switch. And 3 fewer loops to copy/paste.
switch (type) { switch (type) {
case TYPE_UINT8: case TYPE_UINT8:
itemp = PyInt_AsLong(op); itemp = PyInt_AsLong(op);
@ -3101,7 +3101,7 @@ static struct PyMethodDef methods[] = {
{"unsharp_mask", (PyCFunction)_unsharp_mask, 1}, {"unsharp_mask", (PyCFunction)_unsharp_mask, 1},
#endif #endif
{"box_blur", (PyCFunction)_box_blur, 1}, {"box_blur", (PyCFunction)_box_blur, 1},
#ifdef WITH_EFFECTS #ifdef WITH_EFFECTS
/* Special effects */ /* Special effects */

View File

@ -49,7 +49,7 @@ http://www.cazabon.com\n\
/* known to-do list with current version: /* known to-do list with current version:
Verify that PILmode->littleCMStype conversion in findLCMStype is correct for all Verify that PILmode->littleCMStype conversion in findLCMStype is correct for all
PIL modes (it probably isn't for the more obscure ones) PIL modes (it probably isn't for the more obscure ones)
Add support for creating custom RGB profiles on the fly Add support for creating custom RGB profiles on the fly
@ -454,7 +454,7 @@ createProfile(PyObject *self, PyObject *args)
} }
else if (strcmp(sColorSpace, "XYZ") == 0) { else if (strcmp(sColorSpace, "XYZ") == 0) {
hProfile = cmsCreateXYZProfile(); hProfile = cmsCreateXYZProfile();
} }
else if (strcmp(sColorSpace, "sRGB") == 0) { else if (strcmp(sColorSpace, "sRGB") == 0) {
hProfile = cmsCreate_sRGBProfile(); hProfile = cmsCreate_sRGBProfile();
} }
@ -554,10 +554,10 @@ _profile_getattr(CmsProfileObject* self, cmsInfoType field)
{ {
// UNDONE -- check that I'm getting the right fields on these. // UNDONE -- check that I'm getting the right fields on these.
// return PyUnicode_DecodeFSDefault(cmsTakeProductName(self->profile)); // return PyUnicode_DecodeFSDefault(cmsTakeProductName(self->profile));
//wchar_t buf[256]; -- UNDONE need wchar_t for unicode version. //wchar_t buf[256]; -- UNDONE need wchar_t for unicode version.
char buf[256]; char buf[256];
cmsUInt32Number written; cmsUInt32Number written;
written = cmsGetProfileInfoASCII(self->profile, written = cmsGetProfileInfoASCII(self->profile,
field, field,
"en", "en",
"us", "us",
@ -566,40 +566,40 @@ _profile_getattr(CmsProfileObject* self, cmsInfoType field)
if (written) { if (written) {
return PyUnicode_FromString(buf); return PyUnicode_FromString(buf);
} }
// UNDONE suppressing error here by sending back blank string. // UNDONE suppressing error here by sending back blank string.
return PyUnicode_FromString(""); return PyUnicode_FromString("");
} }
static PyObject* static PyObject*
cms_profile_getattr_product_desc(CmsProfileObject* self, void* closure) cms_profile_getattr_product_desc(CmsProfileObject* self, void* closure)
{ {
// description was Description != 'Copyright' || or "%s - %s" (manufacturer, model) in 1.x // description was Description != 'Copyright' || or "%s - %s" (manufacturer, model) in 1.x
return _profile_getattr(self, cmsInfoDescription); return _profile_getattr(self, cmsInfoDescription);
} }
/* use these four for the individual fields. /* use these four for the individual fields.
*/ */
static PyObject* static PyObject*
cms_profile_getattr_product_description(CmsProfileObject* self, void* closure) cms_profile_getattr_product_description(CmsProfileObject* self, void* closure)
{ {
return _profile_getattr(self, cmsInfoDescription); return _profile_getattr(self, cmsInfoDescription);
} }
static PyObject* static PyObject*
cms_profile_getattr_product_model(CmsProfileObject* self, void* closure) cms_profile_getattr_product_model(CmsProfileObject* self, void* closure)
{ {
return _profile_getattr(self, cmsInfoModel); return _profile_getattr(self, cmsInfoModel);
} }
static PyObject* static PyObject*
cms_profile_getattr_product_manufacturer(CmsProfileObject* self, void* closure) cms_profile_getattr_product_manufacturer(CmsProfileObject* self, void* closure)
{ {
return _profile_getattr(self, cmsInfoManufacturer); return _profile_getattr(self, cmsInfoManufacturer);
} }
static PyObject* static PyObject*
cms_profile_getattr_product_copyright(CmsProfileObject* self, void* closure) cms_profile_getattr_product_copyright(CmsProfileObject* self, void* closure)
{ {
return _profile_getattr(self, cmsInfoCopyright); return _profile_getattr(self, cmsInfoCopyright);
} }

View File

@ -128,11 +128,11 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
/* Don't free this before FT_Done_Face */ /* Don't free this before FT_Done_Face */
self->font_bytes = PyMem_Malloc(font_bytes_size); self->font_bytes = PyMem_Malloc(font_bytes_size);
if (!self->font_bytes) { if (!self->font_bytes) {
error = 65; // Out of Memory in Freetype. error = 65; // Out of Memory in Freetype.
} }
if (!error) { if (!error) {
memcpy(self->font_bytes, font_bytes, (size_t)font_bytes_size); memcpy(self->font_bytes, font_bytes, (size_t)font_bytes_size);
error = FT_New_Memory_Face(library, (FT_Byte*)self->font_bytes, error = FT_New_Memory_Face(library, (FT_Byte*)self->font_bytes,
font_bytes_size, index, &self->face); font_bytes_size, index, &self->face);
} }
} }
@ -152,7 +152,7 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
if (error) { if (error) {
if (self->font_bytes) { if (self->font_bytes) {
PyMem_Free(self->font_bytes); PyMem_Free(self->font_bytes);
} }
PyObject_Del(self); PyObject_Del(self);
return geterror(error); return geterror(error);
} }
@ -228,8 +228,8 @@ font_getsize(FontObject* self, PyObject* args)
x += delta.x; x += delta.x;
} }
/* Note: bitmap fonts within ttf fonts do not work, see #891/pr#960 /* Note: bitmap fonts within ttf fonts do not work, see #891/pr#960
* Yifu Yu<root@jackyyf.com>, 2014-10-15 * Yifu Yu<root@jackyyf.com>, 2014-10-15
*/ */
error = FT_Load_Glyph(face, index, FT_LOAD_DEFAULT|FT_LOAD_NO_BITMAP); error = FT_Load_Glyph(face, index, FT_LOAD_DEFAULT|FT_LOAD_NO_BITMAP);
if (error) if (error)
@ -443,7 +443,7 @@ font_dealloc(FontObject* self)
FT_Done_Face(self->face); FT_Done_Face(self->face);
if (self->font_bytes) { if (self->font_bytes) {
PyMem_Free(self->font_bytes); PyMem_Free(self->font_bytes);
} }
PyObject_Del(self); PyObject_Del(self);
} }

View File

@ -109,7 +109,7 @@ apply(PyObject *self, PyObject* args)
unsigned char b7 = nrow[col_idx]&1; unsigned char b7 = nrow[col_idx]&1;
unsigned char b8 = nrow[cip]&1; unsigned char b8 = nrow[cip]&1;
int lut_idx = (b0 int lut_idx = (b0
|(b1 << 1) |(b1 << 1)
|(b2 << 2) |(b2 << 2)
|(b3 << 3) |(b3 << 3)
@ -199,7 +199,7 @@ match(PyObject *self, PyObject* args)
unsigned char b7 = nrow[col_idx]&1; unsigned char b7 = nrow[col_idx]&1;
unsigned char b8 = nrow[cip]&1; unsigned char b8 = nrow[cip]&1;
int lut_idx = (b0 int lut_idx = (b0
|(b1 << 1) |(b1 << 1)
|(b2 << 2) |(b2 << 2)
|(b3 << 3) |(b3 << 3)

View File

@ -33,11 +33,11 @@ Download Python 3.4, install it, and add it to the path. This is the
Python that we will use to bootstrap the build process. (The download Python that we will use to bootstrap the build process. (The download
routines are using 3.2+ features, and installing 3.4 gives us pip and routines are using 3.2+ features, and installing 3.4 gives us pip and
virtualenv as well, reducing the number of packages that we need to virtualenv as well, reducing the number of packages that we need to
install.) install.)
Download the rest of the Pythons by opening a command window, changing Download the rest of the Pythons by opening a command window, changing
to the `winbuild` directory, and running `python to the `winbuild` directory, and running `python
get_pythons.py`. get_pythons.py`.
UNDONE -- gpg verify the signatures (note that we can download from UNDONE -- gpg verify the signatures (note that we can download from
https) https)
@ -67,13 +67,13 @@ Dependencies
The script 'build_dep.py' downloads and builds the dependencies. Open The script 'build_dep.py' downloads and builds the dependencies. Open
a command window, change directory into `winbuild` and run `python a command window, change directory into `winbuild` and run `python
build_dep.py`. build_dep.py`.
This will download libjpeg, libtiff, libz, and freetype. It will then This will download libjpeg, libtiff, libz, and freetype. It will then
compile 32 and 64-bit versions of the libraries, with both versions of compile 32 and 64-bit versions of the libraries, with both versions of
the compilers. the compilers.
UNDONE -- lcms fails. UNDONE -- lcms fails.
UNDONE -- webp, jpeg2k not recognized UNDONE -- webp, jpeg2k not recognized
Building Pillow Building Pillow
@ -82,7 +82,7 @@ Building Pillow
Once the dependencies are built, run `python build.py --clean` to Once the dependencies are built, run `python build.py --clean` to
build and install Pillow in virtualenvs for each python build and install Pillow in virtualenvs for each python
build. `build.py --dist` will build Windows installers instead of build. `build.py --dist` will build Windows installers instead of
installing into virtualenvs. installing into virtualenvs.
UNDONE -- suppressed output, what about failures. UNDONE -- suppressed output, what about failures.

View File

@ -12,12 +12,12 @@ Bands
An image can consist of one or more bands of data. The Python Imaging Library An image can consist of one or more bands of data. The Python Imaging Library
allows you to store several bands in a single image, provided they all have the allows you to store several bands in a single image, provided they all have the
same dimensions and depth. For example, a PNG image might have 'R', 'G', 'B', same dimensions and depth. For example, a PNG image might have 'R', 'G', 'B',
and 'A' bands for the red, green, blue, and alpha transparency values. Many and 'A' bands for the red, green, blue, and alpha transparency values. Many
operations act on each band separately, e.g., histograms. It is often useful to operations act on each band separately, e.g., histograms. It is often useful to
think of each pixel as having one value per band. think of each pixel as having one value per band.
To get the number and names of bands in an image, use the To get the number and names of bands in an image, use the
:py:meth:`~PIL.Image.Image.getbands` method. :py:meth:`~PIL.Image.Image.getbands` method.
.. _concept-modes: .. _concept-modes:
@ -43,7 +43,7 @@ PIL also provides limited support for a few special modes, including ``LA`` (L
with alpha), ``RGBX`` (true color with padding) and ``RGBa`` (true color with with alpha), ``RGBX`` (true color with padding) and ``RGBa`` (true color with
premultiplied alpha). However, PIL doesnt support user-defined modes; if you premultiplied alpha). However, PIL doesnt support user-defined modes; if you
to handle band combinations that are not listed above, use a sequence of Image to handle band combinations that are not listed above, use a sequence of Image
objects. objects.
You can read the mode of an image through the :py:attr:`~PIL.Image.Image.mode` You can read the mode of an image through the :py:attr:`~PIL.Image.Image.mode`
attribute. This is a string containing one of the above values. attribute. This is a string containing one of the above values.

View File

@ -471,13 +471,13 @@ The :py:meth:`~PIL.Image.Image.open` method sets the following
.. versionadded:: 1.1.5 .. versionadded:: 1.1.5
**resolution** **resolution**
Image resolution as an ``(xres, yres)`` tuple, where applicable. This is a Image resolution as an ``(xres, yres)`` tuple, where applicable. This is a
measurement in whichever unit is specified by the file. measurement in whichever unit is specified by the file.
.. versionadded:: 1.1.5 .. versionadded:: 1.1.5
The :py:attr:`~PIL.Image.Image.tag_v2` attribute contains a dictionary of The :py:attr:`~PIL.Image.Image.tag_v2` attribute contains a dictionary of
TIFF metadata. The keys are numerical indexes from `~PIL.TiffTags.TAGS_V2`. TIFF metadata. The keys are numerical indexes from `~PIL.TiffTags.TAGS_V2`.
Values are strings or numbers for single items, multiple values are returned Values are strings or numbers for single items, multiple values are returned
in a tuple of values. Rational numbers are returned as a single value. in a tuple of values. Rational numbers are returned as a single value.

View File

@ -81,7 +81,7 @@ Example: Draw Partial Opacity Text
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
# get an image # get an image
base = Image.open('Pillow/Tests/images/lena.png').convert('RGBA') base = Image.open('Pillow/Tests/images/lena.png').convert('RGBA')
# make a blank image for the text, initialized to transparent text color # make a blank image for the text, initialized to transparent text color
txt = Image.new('RGBA', base.size, (255,255,255,0)) txt = Image.new('RGBA', base.size, (255,255,255,0))
@ -89,7 +89,7 @@ Example: Draw Partial Opacity Text
# get a font # get a font
fnt = ImageFont.truetype('Pillow/Tests/fonts/FreeMono.ttf', 40) fnt = ImageFont.truetype('Pillow/Tests/fonts/FreeMono.ttf', 40)
# get a drawing context # get a drawing context
d = ImageDraw.Draw(txt) d = ImageDraw.Draw(txt)
# draw text, half opacity # draw text, half opacity
d.text((10,10), "Hello", font=fnt, fill=(255,255,255,128)) d.text((10,10), "Hello", font=fnt, fill=(255,255,255,128))

View File

@ -27,7 +27,7 @@ Example: Using the :py:mod:`~PIL.ImageMath` module
In the current version, :py:mod:`~PIL.ImageMath` only supports In the current version, :py:mod:`~PIL.ImageMath` only supports
single-layer images. To process multi-band images, use the single-layer images. To process multi-band images, use the
:py:meth:`~PIL.Image.Image.split` method or :py:func:`~PIL.Image.merge` :py:meth:`~PIL.Image.Image.split` method or :py:func:`~PIL.Image.merge`
function. function.
:param expression: A string which uses the standard Python expression :param expression: A string which uses the standard Python expression

View File

@ -4,7 +4,7 @@
:py:mod:`ImageMorph` Module :py:mod:`ImageMorph` Module
=========================== ===========================
The :py:mod:`ImageMorph` module provides morphology operations on images. The :py:mod:`ImageMorph` module provides morphology operations on images.
.. automodule:: PIL.ImageMorph .. automodule:: PIL.ImageMorph
:members: :members:

View File

@ -7,10 +7,10 @@
The :py:mod:`OleFileIO` module reads Microsoft OLE2 files (also called The :py:mod:`OleFileIO` module reads Microsoft OLE2 files (also called
Structured Storage or Microsoft Compound Document File Format), such Structured Storage or Microsoft Compound Document File Format), such
as Microsoft Office documents, Image Composer and FlashPix files, and as Microsoft Office documents, Image Composer and FlashPix files, and
Outlook messages. Outlook messages.
This module is the `OleFileIO\_PL`_ project by Philippe Lagadec, v0.30, This module is the `OleFileIO\_PL`_ project by Philippe Lagadec, v0.30,
merged back into Pillow. merged back into Pillow.
.. _OleFileIO\_PL: http://www.decalage.info/python/olefileio .. _OleFileIO\_PL: http://www.decalage.info/python/olefileio
@ -300,7 +300,7 @@ Close the OLE file
Unless your application is a simple script that terminates after Unless your application is a simple script that terminates after
processing an OLE file, do not forget to close each OleFileIO object processing an OLE file, do not forget to close each OleFileIO object
after parsing to close the file on disk. after parsing to close the file on disk.
.. code-block:: python .. code-block:: python

View File

@ -6,7 +6,7 @@
The PixelAccess class provides read and write access to The PixelAccess class provides read and write access to
:py:class:`PIL.Image` data at a pixel level. :py:class:`PIL.Image` data at a pixel level.
.. note:: Accessing individual pixels is fairly slow. If you are looping over all of the pixels in an image, there is likely a faster way using other parts of the Pillow API. .. note:: Accessing individual pixels is fairly slow. If you are looping over all of the pixels in an image, there is likely a faster way using other parts of the Pillow API.
Example Example
------- -------

View File

@ -228,7 +228,7 @@ Plugin reference
:mod:`PngImagePlugin` Module :mod:`PngImagePlugin` Module
---------------------------- ----------------------------
.. automodule:: PIL.PngImagePlugin .. automodule:: PIL.PngImagePlugin
:members: ChunkStream, PngImageFile, PngStream, getchunks, is_cid, putchunk :members: ChunkStream, PngImageFile, PngStream, getchunks, is_cid, putchunk
:show-inheritance: :show-inheritance:
.. autoclass:: PIL.PngImagePlugin.ChunkStream .. autoclass:: PIL.PngImagePlugin.ChunkStream

View File

@ -4,8 +4,8 @@
Sane Plugin Sane Plugin
----------- -----------
The Sane plugin has now been split into its own repo: The Sane plugin has now been split into its own repo:
https://github.com/python-pillow/Sane . https://github.com/python-pillow/Sane .
Png text chunk size limits Png text chunk size limits
@ -14,7 +14,7 @@ Png text chunk size limits
To prevent potential denial of service attacks using compressed text To prevent potential denial of service attacks using compressed text
chunks, there are now limits to the decompressed size of text chunks chunks, there are now limits to the decompressed size of text chunks
decoded from PNG images. If the limits are exceeded when opening a PNG decoded from PNG images. If the limits are exceeded when opening a PNG
image a ``ValueError`` will be raised. image a ``ValueError`` will be raised.
Individual text chunks are limited to Individual text chunks are limited to
:py:attr:`PIL.PngImagePlugin.MAX_TEXT_CHUNK`, set to 1MB by :py:attr:`PIL.PngImagePlugin.MAX_TEXT_CHUNK`, set to 1MB by

View File

@ -31,7 +31,7 @@ Deprecated Methods
Several methods that have been marked as deprecated for many releases Several methods that have been marked as deprecated for many releases
have been removed in this release:: have been removed in this release::
Image.tostring() Image.tostring()
Image.fromstring() Image.fromstring()
Image.offset() Image.offset()
ImageDraw.setink() ImageDraw.setink()
@ -47,6 +47,6 @@ LibJpeg and Zlib are Required by Default
The external dependencies on libjpeg and zlib are now required by default. The external dependencies on libjpeg and zlib are now required by default.
If the headers or libraries are not found, then installation will abort If the headers or libraries are not found, then installation will abort
with an error. This behaviour can be disabled with the ``--disable-libjpeg`` with an error. This behaviour can be disabled with the ``--disable-libjpeg``
and ``--disable-zlib`` flags. and ``--disable-zlib`` flags.

View File

@ -554,7 +554,7 @@ static unsigned int* get_qtables_arrays(PyObject* qtables, int* qtablesLen) {
tables = PySequence_Fast(qtables, "expected a sequence"); tables = PySequence_Fast(qtables, "expected a sequence");
num_tables = PySequence_Size(qtables); num_tables = PySequence_Size(qtables);
if (num_tables < 1 || num_tables > NUM_QUANT_TBLS) { if (num_tables < 1 || num_tables > NUM_QUANT_TBLS) {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"Not a valid number of quantization tables. Should be between 1 and 4."); "Not a valid number of quantization tables. Should be between 1 and 4.");
Py_DECREF(tables); Py_DECREF(tables);
return NULL; return NULL;
@ -582,7 +582,7 @@ static unsigned int* get_qtables_arrays(PyObject* qtables, int* qtablesLen) {
Py_DECREF(table_data); Py_DECREF(table_data);
} }
*qtablesLen = num_tables; *qtablesLen = num_tables;
JPEG_QTABLES_ERR: JPEG_QTABLES_ERR:
Py_DECREF(tables); // Run on both error and not error Py_DECREF(tables); // Run on both error and not error

View File

@ -259,14 +259,14 @@ rgb2hsv(UINT8* out, const UINT8* in, int xsize)
g = in[1]; g = in[1];
b = in[2]; b = in[2];
maxc = MAX(r,MAX(g,b)); maxc = MAX(r,MAX(g,b));
minc = MIN(r,MIN(g,b)); minc = MIN(r,MIN(g,b));
uv = maxc; uv = maxc;
if (minc == maxc){ if (minc == maxc){
*out++ = 0; *out++ = 0;
*out++ = 0; *out++ = 0;
*out++ = uv; *out++ = uv;
} else { } else {
cr = (float)(maxc-minc); cr = (float)(maxc-minc);
s = cr/(float)maxc; s = cr/(float)maxc;
rc = ((float)(maxc-r))/cr; rc = ((float)(maxc-r))/cr;
@ -280,7 +280,7 @@ rgb2hsv(UINT8* out, const UINT8* in, int xsize)
h = 4.0 + gc-rc; h = 4.0 + gc-rc;
} }
// incorrect hue happens if h/6 is negative. // incorrect hue happens if h/6 is negative.
h = fmod((h/6.0 + 1.0), 1.0); h = fmod((h/6.0 + 1.0), 1.0);
uh = (UINT8)CLIP((int)(h*255.0)); uh = (UINT8)CLIP((int)(h*255.0));
us = (UINT8)CLIP((int)(s*255.0)); us = (UINT8)CLIP((int)(s*255.0));
@ -313,10 +313,10 @@ hsv2rgb(UINT8* out, const UINT8* in, int xsize)
*out++ = v; *out++ = v;
*out++ = v; *out++ = v;
*out++ = v; *out++ = v;
} else { } else {
i = floor((float)h * 6.0 / 255.0); // 0 - 6 i = floor((float)h * 6.0 / 255.0); // 0 - 6
f = (float)h * 6.0 / 255.0 - (float)i; // 0-1 : remainder. f = (float)h * 6.0 / 255.0 - (float)i; // 0-1 : remainder.
fs = ((float)s)/255.0; fs = ((float)s)/255.0;
p = round((float)v * (1.0-fs)); p = round((float)v * (1.0-fs));
q = round((float)v * (1.0-fs*f)); q = round((float)v * (1.0-fs*f));
@ -326,32 +326,32 @@ hsv2rgb(UINT8* out, const UINT8* in, int xsize)
ut = (UINT8)CLIP(t); ut = (UINT8)CLIP(t);
switch (i%6) { switch (i%6) {
case 0: case 0:
*out++ = v; *out++ = v;
*out++ = ut; *out++ = ut;
*out++ = up; *out++ = up;
break; break;
case 1: case 1:
*out++ = uq; *out++ = uq;
*out++ = v; *out++ = v;
*out++ = up; *out++ = up;
break; break;
case 2: case 2:
*out++ = up; *out++ = up;
*out++ = v; *out++ = v;
*out++ = ut; *out++ = ut;
break; break;
case 3: case 3:
*out++ = up; *out++ = up;
*out++ = uq; *out++ = uq;
*out++ = v; *out++ = v;
break; break;
case 4: case 4:
*out++ = ut; *out++ = ut;
*out++ = up; *out++ = up;
*out++ = v; *out++ = v;
break; break;
case 5: case 5:
*out++ = v; *out++ = v;
*out++ = up; *out++ = up;
*out++ = uq; *out++ = uq;
@ -418,7 +418,7 @@ rgba2rgba(UINT8* out, const UINT8* in, int xsize)
} }
} }
/* RGBa -> RGBA conversion to remove premultiplication /* RGBa -> RGBA conversion to remove premultiplication
Needed for correct transforms/resizing on RGBA images */ Needed for correct transforms/resizing on RGBA images */
static void static void
rgba2rgbA(UINT8* out, const UINT8* in, int xsize) rgba2rgbA(UINT8* out, const UINT8* in, int xsize)
@ -442,13 +442,13 @@ rgba2rgbA(UINT8* out, const UINT8* in, int xsize)
} }
/* /*
* Conversion of RGB + single transparent color to RGBA, * Conversion of RGB + single transparent color to RGBA,
* where any pixel that matches the color will have the * where any pixel that matches the color will have the
* alpha channel set to 0 * alpha channel set to 0
*/ */
static void static void
rgbT2rgba(UINT8* out, int xsize, int r, int g, int b) rgbT2rgba(UINT8* out, int xsize, int r, int g, int b)
{ {
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
UINT32 trns = ((r & 0xff)<<24) | ((g & 0xff)<<16) | ((b & 0xff)<<8) | 0xff; UINT32 trns = ((r & 0xff)<<24) | ((g & 0xff)<<16) | ((b & 0xff)<<8) | 0xff;
@ -1334,8 +1334,8 @@ ImagingConvertTransparent(Imaging imIn, const char *mode,
return (Imaging) ImagingError_ModeError(); return (Imaging) ImagingError_ModeError();
} }
if (!((strcmp(imIn->mode, "RGB") == 0 || if (!((strcmp(imIn->mode, "RGB") == 0 ||
strcmp(imIn->mode, "L") == 0) strcmp(imIn->mode, "L") == 0)
&& strcmp(mode, "RGBA") == 0)) && strcmp(mode, "RGBA") == 0))
#ifdef notdef #ifdef notdef
{ {
@ -1370,7 +1370,7 @@ ImagingConvertTransparent(Imaging imIn, const char *mode,
} }
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
return imOut; return imOut;
} }

View File

@ -175,7 +175,7 @@ ImagingIncrementalCodecCreate(ImagingIncrementalCodecEntry codec_entry,
codec->state = state; codec->state = state;
codec->result = 0; codec->result = 0;
codec->stream.fd = fd; codec->stream.fd = fd;
codec->stream.buffer = codec->stream.ptr = codec->stream.end codec->stream.buffer = codec->stream.ptr = codec->stream.end
= codec->stream.top = NULL; = codec->stream.top = NULL;
codec->started = 0; codec->started = 0;
codec->seekable = seekable; codec->seekable = seekable;
@ -294,7 +294,7 @@ ImagingIncrementalCodecDestroy(ImagingIncrementalCodec codec)
if (codec->seekable && codec->stream.fd < 0) if (codec->seekable && codec->stream.fd < 0)
free (codec->stream.buffer); free (codec->stream.buffer);
codec->stream.buffer = codec->stream.ptr = codec->stream.end codec->stream.buffer = codec->stream.ptr = codec->stream.end
= codec->stream.top = NULL; = codec->stream.top = NULL;
#ifdef _WIN32 #ifdef _WIN32

View File

@ -68,7 +68,7 @@ j2k_skip(OPJ_OFF_T p_nb_bytes, void *p_user_data)
typedef void (*j2k_unpacker_t)(opj_image_t *in, typedef void (*j2k_unpacker_t)(opj_image_t *in,
const JPEG2KTILEINFO *tileInfo, const JPEG2KTILEINFO *tileInfo,
const UINT8 *data, const UINT8 *data,
Imaging im); Imaging im);
struct j2k_decode_unpacker { struct j2k_decode_unpacker {
@ -625,7 +625,7 @@ j2k_decode_entry(Imaging im, ImagingCodecState state,
} }
} }
/* /*
Colorspace Number of components PIL mode Colorspace Number of components PIL mode
------------------------------------------------------ ------------------------------------------------------
sRGB 3 RGB sRGB 3 RGB
@ -668,7 +668,7 @@ j2k_decode_entry(Imaging im, ImagingCodecState state,
if (!unpack) { if (!unpack) {
state->errcode = IMAGING_CODEC_BROKEN; state->errcode = IMAGING_CODEC_BROKEN;
state->state = J2K_STATE_FAILED; state->state = J2K_STATE_FAILED;
goto quick_exit; goto quick_exit;
} }
/* Decode the image tile-by-tile; this means we only need use as much /* Decode the image tile-by-tile; this means we only need use as much

View File

@ -303,7 +303,7 @@ j2k_encode_entry(Imaging im, ImagingCodecState state,
prec = 16; prec = 16;
bpp = 12; bpp = 12;
} else if (strcmp (im->mode, "LA") == 0) { } else if (strcmp (im->mode, "LA") == 0) {
components = 2; components = 2;
color_space = OPJ_CLRSPC_GRAY; color_space = OPJ_CLRSPC_GRAY;
pack = j2k_pack_la; pack = j2k_pack_la;
} else if (strcmp (im->mode, "RGB") == 0) { } else if (strcmp (im->mode, "RGB") == 0) {
@ -544,8 +544,8 @@ ImagingJpeg2KEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes)
return -1; return -1;
if (state->state == J2K_STATE_START) { if (state->state == J2K_STATE_START) {
int seekable = (context->format != OPJ_CODEC_J2K int seekable = (context->format != OPJ_CODEC_J2K
? INCREMENTAL_CODEC_SEEKABLE ? INCREMENTAL_CODEC_SEEKABLE
: INCREMENTAL_CODEC_NOT_SEEKABLE); : INCREMENTAL_CODEC_NOT_SEEKABLE);
context->encoder = ImagingIncrementalCodecCreate(j2k_encode_entry, context->encoder = ImagingIncrementalCodecCreate(j2k_encode_entry,

View File

@ -300,7 +300,7 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
if (context->qtables) { if (context->qtables) {
free(context->qtables); free(context->qtables);
context->qtables = NULL; context->qtables = NULL;
} }
jpeg_destroy_compress(&context->cinfo); jpeg_destroy_compress(&context->cinfo);
/* if (jerr.pub.num_warnings) return BROKEN; */ /* if (jerr.pub.num_warnings) return BROKEN; */

View File

@ -400,7 +400,7 @@ ImagingPackLAB(UINT8* out, const UINT8* in, int pixels)
/* LAB triplets */ /* LAB triplets */
for (i = 0; i < pixels; i++) { for (i = 0; i < pixels; i++) {
out[0] = in[0]; out[0] = in[0];
out[1] = in[1] ^ 128; /* signed in outside world */ out[1] = in[1] ^ 128; /* signed in outside world */
out[2] = in[2] ^ 128; out[2] = in[2] ^ 128;
out += 3; in += 4; out += 3; in += 4;
} }

View File

@ -62,8 +62,8 @@ ImagingPcxDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
int stride = state->bytes / bands; int stride = state->bytes / bands;
int i; int i;
for (i=1; i< bands; i++) { // note -- skipping first band for (i=1; i< bands; i++) { // note -- skipping first band
memmove(&state->buffer[i*state->xsize], memmove(&state->buffer[i*state->xsize],
&state->buffer[i*stride], &state->buffer[i*stride],
state->xsize); state->xsize);
} }
} }

View File

@ -94,10 +94,10 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
while (state->x < planes * bytes_per_line) { while (state->x < planes * bytes_per_line) {
/* If we're encoding an odd width file, and we've /* If we're encoding an odd width file, and we've
got more than one plane, we need to pad each got more than one plane, we need to pad each
color row with padding bytes at the end. Since color row with padding bytes at the end. Since
The pixels are stored RRRRRGGGGGBBBBB, so we need The pixels are stored RRRRRGGGGGBBBBB, so we need
to have the padding be RRRRRPGGGGGPBBBBBP. Hence to have the padding be RRRRRPGGGGGPBBBBBP. Hence
the double loop the double loop
*/ */
while (state->x % bytes_per_line) { while (state->x % bytes_per_line) {
@ -174,8 +174,8 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
} }
/* reset for the next color plane. */ /* reset for the next color plane. */
if (state->x < planes * bytes_per_line) { if (state->x < planes * bytes_per_line) {
state->count = 1; state->count = 1;
state->LAST = state->buffer[state->x]; state->LAST = state->buffer[state->x];
state->x++; state->x++;
} }
} }

View File

@ -758,13 +758,13 @@ unpackCMYKI(UINT8* out, const UINT8* in, int pixels)
/* Unpack to "LAB" image */ /* Unpack to "LAB" image */
/* There are two representations of LAB images for whatever precision: /* There are two representations of LAB images for whatever precision:
L: Uint (in PS, it's 0-100) L: Uint (in PS, it's 0-100)
A: Int (in ps, -128 .. 128, or elsewhere 0..255, with 128 as middle. A: Int (in ps, -128 .. 128, or elsewhere 0..255, with 128 as middle.
Channels in PS display a 0 value as middle grey, Channels in PS display a 0 value as middle grey,
LCMS appears to use 128 as the 0 value for these channels) LCMS appears to use 128 as the 0 value for these channels)
B: Int (as above) B: Int (as above)
Since we don't have any signed ints, we're going with the shifted versions Since we don't have any signed ints, we're going with the shifted versions
internally, and we'll unshift for saving and whatnot. internally, and we'll unshift for saving and whatnot.
*/ */
void void
ImagingUnpackLAB(UINT8* out, const UINT8* in, int pixels) ImagingUnpackLAB(UINT8* out, const UINT8* in, int pixels)
@ -802,15 +802,15 @@ unpackI16N_I16(UINT8* out, const UINT8* in, int pixels){
static void static void
unpackI12_I16(UINT8* out, const UINT8* in, int pixels){ unpackI12_I16(UINT8* out, const UINT8* in, int pixels){
/* Fillorder 1/MSB -> LittleEndian, for 12bit integer greyscale tiffs. /* Fillorder 1/MSB -> LittleEndian, for 12bit integer greyscale tiffs.
According to the TIFF spec: According to the TIFF spec:
FillOrder = 2 should be used only when BitsPerSample = 1 and FillOrder = 2 should be used only when BitsPerSample = 1 and
the data is either uncompressed or compressed using CCITT 1D the data is either uncompressed or compressed using CCITT 1D
or 2D compression, to avoid potentially ambiguous situations. or 2D compression, to avoid potentially ambiguous situations.
Yeah. I thought so. We'll see how well people read the spec. Yeah. I thought so. We'll see how well people read the spec.
We've got several fillorder=2 modes in TiffImagePlugin.py We've got several fillorder=2 modes in TiffImagePlugin.py
There's no spec I can find. It appears that the in storage There's no spec I can find. It appears that the in storage