Merge pull request #2100 from radarhere/flake8

Flake8 and whitespace fixes
This commit is contained in:
Hugo 2016-09-03 12:41:06 +03:00 committed by GitHub
commit 6009e867e8
41 changed files with 178 additions and 176 deletions

View File

@ -18,7 +18,7 @@ Changelog (Pillow)
- Skip failing numpy tests on Pypy <= 5.3.1 #2090
[arjennienhuis]
- Show warning when trying to save RGBA image as JPEG #2010
[homm]
@ -33,16 +33,16 @@ Changelog (Pillow)
- Add ImageOps.scale to expand or contract a PIL image by a factor #2011
[vlmath]
- Flake8 fixes #2050
[hugovk]
- Updated freetype to 2.6.5 on Appveyor builds #2035
[radarhere]
- PCX encoder fixes #2023, pr #2041
[homm]
- Docs: Windows console prompts are > #2031
[techtonik]
@ -72,7 +72,7 @@ Changelog (Pillow)
- Fix issue converting P mode to LA #1986
[didrix]
- Moved test_j2k_overflow to check_j2k_overflow, prevent DOS of our 32bit testing machines #1995
[wiredfool]
@ -99,10 +99,10 @@ Changelog (Pillow)
- test_imagecms: Reduce precision of extended info due to 32 bit machine precision #1990
[AbdealiJK]
- Binary Tiff Metadata/ICC profile. #1988
[wiredfool]
- Ignore large text blocks in PNG if LOAD_TRUNCATED_IMAGES is enabled #1970
[homm]
@ -111,7 +111,7 @@ Changelog (Pillow)
- Skip extra 0xff00 in jpeg #1977
[kkopachev]
- Use bytearray for palette mutable storage #1985
[radarhere, wiredfool]
@ -123,7 +123,7 @@ Changelog (Pillow)
- Changed depends/install_*.sh urls to point to github pillow-depends repo #1983
[wiredfool]
- Allow ICC profile from `encoderinfo` while saving PNGs #1909
[homm]
@ -138,7 +138,7 @@ Changelog (Pillow)
- Change equals method on Image so it short circuits #1967
[mattBoros]
- Runtime loading of TCL/TK libraries, eliminating build time dependency. #1932
[matthew-brett]
@ -300,7 +300,7 @@ Changelog (Pillow)
- Added install docs for Fedora 23 and FreeBSD #1729, #1739, #1792
[koobs, zandermartin, wiredfool]
- Fixed TIFF multiframe load when the frames have different compression types #1782
[radarhere, geka000]
@ -309,7 +309,7 @@ Changelog (Pillow)
- Updated dates in PIL license in OleFileIO README #1787
[radarhere]
- Corrected Tiff tag names #1786
[radarhere]
@ -360,7 +360,7 @@ Changelog (Pillow)
- Add a loader for the FTEX format from Independence War 2: Edge of Chaos #1688
[jleclanche]
- Improved alpha_composite documentation #1698
[radarhere]
@ -378,7 +378,7 @@ Changelog (Pillow)
- Fixed support for .gbr version 1 images, added support for version 2 in GbrImagePlugin #1653
[wiredfool]
- Clarified which YCbCr format is used #1677
[radarhere]
@ -455,7 +455,7 @@ Changelog (Pillow)
- Updated installation docs for new versions of dependencies #1611
[radarhere]
- Removed unrunnable test file #1610
[radarhere]
@ -464,7 +464,7 @@ Changelog (Pillow)
- Added field type constants to TiffTags #1596
[radarhere]
- Allow saving RowsPerStrip with libtiff #1594
[wiredfool]
@ -473,10 +473,10 @@ Changelog (Pillow)
- Changed some urls in the docs to use https #1580
[hugovk]
- Removed logger.exception from ImageFile.py #1590
[radarhere]
- Removed warnings module check #1587
[radarhere]
@ -491,7 +491,7 @@ Changelog (Pillow)
- Consistent multiline text spacing #1574
[wiredfool, hugovk]
- Removed unused lines in BDFFontFile #1530
[radarhere]
@ -509,19 +509,19 @@ Changelog (Pillow)
- Docs and code health fixes #1565 #1566 #1581 #1586 #1591 #1621
[radarhere]
- Updated freetype to 2.6.2 #1564
[radarhere]
- Updated WebP to 0.5.0 for Travis #1515 #1609
[radarhere]
- Fix missing 'version' key value in __array_interface__ #1519
[mattip]
- Replaced os.popen with subprocess.Popen to pilprint script #1523
[radarhere]
- Catch OverflowError in SpiderImagePlugin #1545
[radarhere, MrShark]
@ -533,7 +533,7 @@ Changelog (Pillow)
- Fix Exception when requiring jpeg #1501
[hansmosh]
- Dependency scripts for Debian and Ubuntu #1486
[wiredfool]
@ -566,28 +566,28 @@ Changelog (Pillow)
- Added PDF multipage saving #1445
[radarhere]
- Removed deprecated code, Image.tostring, Image.fromstring, Image.offset, ImageDraw.setink, ImageDraw.setfill, ImageFileIO, ImageFont.FreeTypeFont and ImageFont.truetype `file` kwarg, ImagePalette private _make functions, ImageWin.fromstring and ImageWin.tostring #1343
[radarhere]
- Load more broken images #1428
[homm]
- Require zlib and libjpeg #1439
[wiredfool]
- Preserve alpha when converting from a QImage to a Pillow Image by using png instead of ppm #1429
[ericfrederich]
- Qt needs 32 bit aligned image data #1430
[ericfrederich]
- Tiff ImageFileDirectory rewrite #1419
[anntzer, wiredfool, homm]
- Removed spammy debug logging #1423
[wiredfool]
- Save as GiF89a with support for animation parameters #1384
[radarhere]
@ -608,19 +608,19 @@ Changelog (Pillow)
- Single threaded build for pypy3, refactor #1413
[wiredfool]
- Fix loading of truncated images with LOAD_TRUNCATED_IMAGES enabled #1366
[homm]
- Documentation update for concepts: bands
[merriam]
- Add Solaris/SmartOS include and library directories #1356
[njones11]
- Improved handling of getink color #1387
[radarhere]
- Disable compiler optimizations for topalette and tobilevel functions for all msvc versions, fixes #1357
[cgohlke]
@ -656,10 +656,10 @@ Changelog (Pillow)
- Fix fast rotate operations #1373
[radarhere]
- Added support for pathlib Path objects to open and save #1372
[radarhere]
- Changed register calls to use format property #1333
[radarhere]
@ -677,7 +677,7 @@ Changelog (Pillow)
- Added various tests #1330, #1344
[radarhere]
- More ImageFont tests #1327
[hugovk]
@ -704,10 +704,10 @@ Changelog (Pillow)
- Added width and height properties #1304
[radarhere]
- Update tiff and tk tcl 8.5 versions #1303
[radarhere, wiredfool]
- Add functions to convert: Image <-> QImage; Image <-> QPixmap #1217
[radarhere, rominf]
@ -716,19 +716,19 @@ Changelog (Pillow)
- Multiline text in ImageDraw #1177
[allo-, radarhere]
- Automated Windows CI/build support #1278
[wiredfool]
- Removed support for Tk versions earlier than 8.4 #1288
[radarhere]
- Fixed polygon edge drawing #1255 (fixes #1252)
[radarhere]
- Check prefix length in _accept methods #1267
[radarhere]
- Register MIME type for BMP #1277
[coldmind]
@ -737,7 +737,7 @@ Changelog (Pillow)
- Identify XBM file created with filename including underscore #1230 (fixes #1229)
[hugovk]
- Copy image when saving in GifImagePlugin #1231 (fixes #718)
[radarhere]
@ -761,7 +761,7 @@ Changelog (Pillow)
- Setting transparency value to 0 when the tRNS contains only null byte(s) #1239
[juztin]
- Separated out feature checking from selftest #1233
[radarhere]
@ -830,7 +830,7 @@ Changelog (Pillow)
- Fix ImagingEffectNoise #1128
[hugovk]
- Remove unreachable code
[hugovk]
@ -842,13 +842,13 @@ Changelog (Pillow)
- Fast path for opaque pixels in RGBa unpacker #1088
[bgilbert]
- Enable basic support for 'RGBa' raw encoding/decoding #1096
[immerrr]
- Fix pickling L mode images with no palette, #1095
[hugovk]
- iPython display hook #1091
[wiredfool]
@ -872,13 +872,13 @@ Changelog (Pillow)
- Use underscores, not spaces, in TIFF tag kwargs. #1044, #1058
[anntzer, hugovk]
- Update PSDraw for Python3, add tests. #1055
[hugovk]
- Use Bicubic filtering by default for thumbnails. Don't use Jpeg Draft mode for thumbnails. #1029
[homm]
- Fix MSVC compiler error: Use Py_ssize_t instead of ssize_t #1051
[cgohlke]
@ -902,7 +902,7 @@ Changelog (Pillow)
- Fix for saving TIFF image into an io.BytesIO buffer #1011
[mfergie]
- Fix antialias compilation on debug versions of Python #1010
[wiredfool]
@ -914,7 +914,7 @@ Changelog (Pillow)
- Use PyQt4 if it has already been imported, otherwise prefer PyQt5. #1003
[AurelienBallier]
- Speedup resample implementation up to 2.5 times. #977
[homm]
@ -935,7 +935,7 @@ Changelog (Pillow)
- Webp Metadata Skip Test comments #954
[wiredfool]
- Fixes for things rpmlint complains about #942
[manisandro]
@ -953,7 +953,7 @@ Changelog (Pillow)
- Fix SciPy regression in Image.resize #945
[wiredfool]
- Fix manifest to include all test files.
[aclark4life]
@ -971,13 +971,13 @@ Changelog (Pillow)
- Use redistributable ICC profiles for testing, skip if not available #923
[wiredfool]
- Additional documentation for JPEG info and save options #890
[wiredfool]
- Fix JPEG Encoding memory leak when exif or qtables were specified
[wiredfool]
- Image.tobytes() and Image.tostring() documentation update #916 #917
[mgedmin]
@ -1043,7 +1043,7 @@ Changelog (Pillow)
- Added support for reading MPO files
[Feneric]
- Added support for encoding and decoding iTXt chunks #818
[dolda2000]
@ -1093,7 +1093,7 @@ Changelog (Pillow)
- Fixed CVE-2014-3589, a DOS in the IcnsImagePlugin (backport)
[Andrew Drake]
2.5.1 (2014-07-10)
------------------
@ -1114,10 +1114,10 @@ Changelog (Pillow)
- Prevent shell injection #748
[mbrown1413, wiredfool]
- Support for Resolution in BMP files #734
[gcq]
- Fix error in setup.py for Python 3
[matthew-brett]

View File

@ -883,7 +883,7 @@ class Image(object):
try:
t = trns_im.palette.getcolor(t)
except:
raise ValueError("Couldn't allocate a palette "+
raise ValueError("Couldn't allocate a palette " +
"color for transparency")
trns_im.putpixel((0, 0), t)

View File

@ -226,7 +226,7 @@ class ImageFile(Image.Image):
if n < 0:
break
b = b[n:]
# Need to cleanup here to prevent leaks in PyPy
decoder.cleanup()
@ -473,7 +473,7 @@ def _save(im, fp, tile, bufsize=0):
e.setimage(im.im, b)
if e.pushes_fd:
e.setfd(fp)
l,s = e.encode_to_pyfd()
l, s = e.encode_to_pyfd()
else:
while True:
l, s, d = e.encode(bufsize)
@ -492,7 +492,7 @@ def _save(im, fp, tile, bufsize=0):
e.setimage(im.im, b)
if e.pushes_fd:
e.setfd(fp)
l,s = e.encode_to_pyfd()
l, s = e.encode_to_pyfd()
else:
s = e.encode_to_file(fh, bufsize)
if s < 0:

View File

@ -85,7 +85,7 @@ def _parse_jp2_header(fp):
mode = None
bpc = None
nc = None
hio = io.BytesIO(header)
while True:
lbox, tbox = struct.unpack('>I4s', hio.read(8))
@ -144,7 +144,7 @@ def _parse_jp2_header(fp):
if size is None or mode is None:
raise SyntaxError("Malformed jp2 header")
return (size, mode)
##

View File

@ -169,7 +169,7 @@ TAGS_V2 = {
45056: ("MPFVersion", UNDEFINED, 1),
45057: ("NumberOfImages", LONG, 1),
45058: ("MPEntry", UNDEFINED, 1),
45059: ("ImageUIDList", UNDEFINED, 0), # UNDONE, check
45059: ("ImageUIDList", UNDEFINED, 0), # UNDONE, check
45060: ("TotalFrames", LONG, 1),
45313: ("MPIndividualNum", LONG, 1),
45569: ("PanOrientation", LONG, 1),

View File

@ -32,6 +32,7 @@ for r in range(8):
for b in range(4):
PALETTE = PALETTE + (o8((r*255)//7)+o8((g*255)//7)+o8((b*255)//3))
def _accept(prefix):
return prefix[:6] == _MAGIC

View File

@ -11,7 +11,7 @@ if hasattr(sys, 'pypy_find_executable'):
# Tested with packages at https://bitbucket.org/pypy/pypy/downloads.
# PyPies 1.6, 2.0 do not have tkinter built in. PyPy3-2.3.1 gives an
# OSError trying to import tkinter. Otherwise:
try: # PyPy 5.1, 4.0.0, 2.6.1, 2.6.0
try: # PyPy 5.1, 4.0.0, 2.6.1, 2.6.0
TKINTER_LIB = tk.tklib_cffi.__file__
except AttributeError:
# PyPy3 2.4, 2.1-beta1; PyPy 2.5.1, 2.5.0, 2.4.0, 2.3, 2.2, 2.1

View File

@ -11,7 +11,7 @@ Install::
pip install coverage nose
If you're using Python 2.6, there's one additional dependency::
pip install unittest2
Execution

View File

@ -71,7 +71,6 @@ class TestFileEps(PillowTestCase):
target = Image.open('Tests/images/pil_sample_rgb.jpg')
self.assert_image_similar(cmyk_image, target, 10)
def test_file_object(self):
# issue 479
image1 = Image.open(file1)

View File

@ -35,7 +35,7 @@ class TestFileJpeg2k(PillowTestCase):
im = Image.open('Tests/images/test-card-lossless.jp2')
px = im.load()
self.assertEqual(px[0,0], (0, 0, 0))
self.assertEqual(px[0, 0], (0, 0, 0))
self.assertEqual(im.mode, 'RGB')
self.assertEqual(im.size, (640, 480))
self.assertEqual(im.format, 'JPEG2000')

View File

@ -472,11 +472,11 @@ class TestFileTiff(PillowTestCase):
tmpfile = self.tempfile("temp.tif")
im.save(tmpfile)
reloaded = Image.open(tmpfile)
self.assert_image_equal(im, reloaded)
if __name__ == '__main__':
unittest.main()

View File

@ -48,7 +48,7 @@ class TestImagingCoreResampleAccuracy(PillowTestCase):
rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), color)
rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), color)
return Image.merge(mode, [case] * len(mode))
return Image.merge(mode, [case] * len(mode))
def make_sample(self, data, size):
"""Restores a sample image from given data string which contains

View File

@ -264,6 +264,7 @@ class TestImageCms(PillowTestCase):
# Helper function to reduce precision of tuples of floats
# recursively and then check equality.
power = 10 ** digits
def truncate_tuple(tuple_or_float):
return tuple(
truncate_tuple(val) if isinstance(val, tuple)

View File

@ -81,7 +81,7 @@ class TestImageOps(PillowTestCase):
def test_scale(self):
# Test the scaling function
i = hopper("L").resize((50, 50))
with self.assertRaises(ValueError):
ImageOps.scale(i, -1)

View File

@ -20,7 +20,8 @@ TEST_IMAGE_SIZE = (10, 10)
# the repr is that of a PIL.Image. Size and shape are 1 and (), not the
# size and shape of the array. This causes failures in several tests.
SKIP_NUMPY_ON_PYPY = hasattr(sys, 'pypy_version_info') and (
sys.pypy_version_info <= (5,3,1,'final',0))
sys.pypy_version_info <= (5, 3, 1, 'final', 0))
class TestNumpy(PillowTestCase):
@ -137,14 +138,14 @@ class TestNumpy(PillowTestCase):
numpy.testing.assert_array_equal(arr, arr_back)
def test_save_tiff_uint16(self):
# Tests that we're getting the pixel value in the right byte order.
# Tests that we're getting the pixel value in the right byte order.
pixel_value = 0x1234
a = numpy.array([pixel_value] * TEST_IMAGE_SIZE[0] * TEST_IMAGE_SIZE[1], dtype=numpy.uint16)
a.shape = TEST_IMAGE_SIZE
img = Image.fromarray(a)
img_px = img.load()
self.assertEqual(img_px[0,0], pixel_value)
self.assertEqual(img_px[0, 0], pixel_value)
@unittest.skipIf(SKIP_NUMPY_ON_PYPY, "numpy.array(Image) is flaky on PyPy")
def test_to_array(self):

View File

@ -364,17 +364,17 @@ getbands(const char* mode)
static void*
getlist(PyObject* arg, Py_ssize_t* length, const char* wrong_length, int type)
{
/* - allocates and returns a c array of the items in the
/* - allocates and returns a c array of the items in the
python sequence arg.
- the size of the returned array is in length
- all of the arg items must be numeric items of the type
- all of the arg items must be numeric items of the type
specified in type
- sequence length is checked against the length parameter IF
an error parameter is passed in wrong_length
- caller is responsible for freeing the memory
- caller is responsible for freeing the memory
*/
Py_ssize_t i, n;
Py_ssize_t i, n;
int itemp;
double dtemp;
void* list;

View File

@ -119,9 +119,9 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
PyMem_Free(filename);
return NULL;
}
self->face = NULL;
if (filename && font_bytes_size <= 0) {
self->font_bytes = NULL;
error = FT_New_Face(library, filename, index, &self->face);
@ -246,11 +246,11 @@ font_getsize(FontObject* self, PyObject* args)
y_max = bbox.yMax;
if (bbox.yMin < y_min)
y_min = bbox.yMin;
/* find max distance of baseline from top */
if (face->glyph->metrics.horiBearingY > yoffset)
yoffset = face->glyph->metrics.horiBearingY;
last_index = index;
FT_Done_Glyph(glyph);
}

View File

@ -231,7 +231,7 @@ get_on_pixels(PyObject *self, PyObject* args)
int row_idx, col_idx;
int width, height;
PyObject *ret = PyList_New(0);
if (!PyArg_ParseTuple(args, "n", &i0)) {
PyErr_SetString(PyExc_RuntimeError, "Argument parsing problem");
@ -241,7 +241,7 @@ get_on_pixels(PyObject *self, PyObject* args)
rows = img->image8;
width = img->xsize;
height = img->ysize;
for (row_idx=0; row_idx < height; row_idx++) {
UINT8 *row = rows[row_idx];
for (col_idx=0; col_idx<width; col_idx++) {

View File

@ -24,4 +24,4 @@ e.g.::
$ source ~/vpy27/bin/activate
$ make install
$ make test

View File

@ -29,7 +29,7 @@ RUN apk --no-cache add python \
RUN apk --no-cache add git \
bash \
sudo
RUN git clone https://github.com/python-pillow/Pillow.git /Pillow
RUN pip install virtualenv && virtualenv /vpy && source /vpy/bin/activate && pip install nose

View File

@ -16,7 +16,7 @@ explicitly.
Fully supported formats
-----------------------
.. contents::
.. contents::
BMP
^^^

View File

@ -282,7 +282,7 @@ Building on Linux
^^^^^^^^^^^^^^^^^
If you didn't build Python from source, make sure you have Python's
development libraries installed.
development libraries installed.
In Debian or Ubuntu::
@ -295,10 +295,10 @@ Or for Python 3::
In Fedora, the command is::
$ sudo dnf install python-devel redhat-rpm-config
Or for Python 3::
$ sudo dnf install python3-devel redhat-rpm-config
$ sudo dnf install python3-devel redhat-rpm-config
.. Note:: ``redhat-rpm-config`` is required on Fedora 23, but not earlier versions.

View File

@ -15,7 +15,7 @@ The following script loads an image, accesses one pixel from it, then
changes it.
.. code-block:: python
from PIL import Image
im = Image.open('hopper.jpg')
px = im.load()
@ -28,7 +28,7 @@ Results in the following::
(23, 24, 68)
(0, 0, 0)
:py:class:`PixelAccess` Class
-----------------------------------
@ -43,9 +43,9 @@ Results in the following::
:param xy: The pixel coordinate, given as (x, y).
:param value: The pixel value.
.. method:: __getitem__(self, xy):
Returns the pixel at x,y. The pixel is returned as a single
value for single band images or a tuple for multiple band
images
@ -62,9 +62,9 @@ Results in the following::
:param xy: The pixel coordinate, given as (x, y).
:param value: The pixel value.
.. method:: getpixel(self, xy):
Returns the pixel at x,y. The pixel is returned as a single
value for single band images or a tuple for multiple band
images

View File

@ -16,7 +16,7 @@ Example
The following script loads an image, accesses one pixel from it, then changes it.
.. code-block:: python
from PIL import Image
im = Image.open('hopper.jpg')
px = im.load()
@ -29,7 +29,7 @@ Results in the following::
(23, 24, 68)
(0, 0, 0)
:py:class:`PyAccess` Class
--------------------------

View File

@ -25,7 +25,7 @@ metadata tag numbers, names, and type information.
:param type: Integer type from :py:attr:`PIL.TiffTags.TYPES`
:param length: Array length: 0 == variable, 1 == single value, n = fixed
:param enum: Dict of name:integer value options for an enumeration
.. method:: cvt_enum(self, value)
:param value: The enumerated value name

View File

@ -161,7 +161,7 @@ _encode_to_pyfd(ImagingEncoderObject* encoder, PyObject* args)
status = encoder->encode(encoder->im, &encoder->state,
(UINT8*) NULL, 0);
result = Py_BuildValue("ii", status, encoder->state.errcode);
return result;
@ -291,7 +291,7 @@ _setfd(ImagingEncoderObject* encoder, PyObject* args)
Py_XINCREF(fd);
state->fd = fd;
Py_INCREF(Py_None);
return Py_None;
}

View File

@ -294,7 +294,7 @@ rgb2hsv(UINT8* out, const UINT8* in, int xsize)
r = in[0];
g = in[1];
b = in[2];
maxc = MAX(r,MAX(g,b));
minc = MIN(r,MIN(g,b));
uv = maxc;
@ -324,7 +324,7 @@ rgb2hsv(UINT8* out, const UINT8* in, int xsize)
*out++ = uh;
*out++ = us;
*out++ = uv;
}
*out++ = in[3];
}
@ -333,18 +333,18 @@ rgb2hsv(UINT8* out, const UINT8* in, int xsize)
static void
hsv2rgb(UINT8* out, const UINT8* in, int xsize)
{ // following colorsys.py
int p,q,t;
UINT8 up,uq,ut;
int i, x;
float f, fs;
UINT8 h,s,v;
for (x = 0; x < xsize; x++, in += 4) {
h = in[0];
s = in[1];
v = in[2];
if (s==0){
*out++ = v;
*out++ = v;
@ -360,7 +360,7 @@ hsv2rgb(UINT8* out, const UINT8* in, int xsize)
up = (UINT8)CLIP(p);
uq = (UINT8)CLIP(q);
ut = (UINT8)CLIP(t);
switch (i%6) {
case 0:
*out++ = v;
@ -392,7 +392,7 @@ hsv2rgb(UINT8* out, const UINT8* in, int xsize)
*out++ = up;
*out++ = uq;
break;
}
}
*out++ = in[3];
@ -481,7 +481,7 @@ rgba2rgbA(UINT8* out, const UINT8* in, int xsize)
* where any pixel that matches the color will have the
* alpha channel set to 0
*/
static void
rgbT2rgba(UINT8* out, int xsize, int r, int g, int b)
{
@ -502,7 +502,7 @@ rgbT2rgba(UINT8* out, int xsize, int r, int g, int b)
}
}
}
/* ---------------- */
/* CMYK conversions */
@ -1383,7 +1383,7 @@ ImagingConvertTransparent(Imaging imIn, const char *mode,
if (!imIn){
return (Imaging) ImagingError_ModeError();
}
if (!((strcmp(imIn->mode, "RGB") == 0 ||
strcmp(imIn->mode, "L") == 0)
&& strcmp(mode, "RGBA") == 0))

View File

@ -142,7 +142,7 @@ ImagingTranspose(Imaging imOut, Imaging imIn)
}
ImagingSectionEnter(&cookie);
if (imIn->image8)
TRANSPOSE(image8)
else
@ -692,7 +692,7 @@ ImagingScaleAffine(Imaging imOut, Imaging imIn,
x1 = imOut->xsize;
if (y1 > imOut->ysize)
y1 = imOut->ysize;
/* malloc check ok, uses calloc for overflow */
xintab = (int*) calloc(imOut->xsize, sizeof(int));
if (!xintab) {
@ -780,7 +780,7 @@ affine_fixed(Imaging imOut, Imaging imIn,
/* use 16.16 fixed point arithmetics */
#define FIX(v) FLOOR((v)*65536.0 + 0.5)
a0 = FIX(a[0]); a1 = FIX(a[1]);
a0 = FIX(a[0]); a1 = FIX(a[1]);
a3 = FIX(a[3]); a4 = FIX(a[4]);
a2 = FIX(a[2] + a[0] * 0.5 + a[1] * 0.5);
a5 = FIX(a[5] + a[3] * 0.5 + a[4] * 0.5);
@ -873,7 +873,7 @@ ImagingTransformAffine(Imaging imOut, Imaging imIn,
/* FIXME: cannot really think of any reasonable case when the
following code is used. maybe we should fall back on the slow
generic transform engine in this case? */
ImagingCopyInfo(imOut, imIn);
xsize = (int) imIn->xsize;

View File

@ -40,7 +40,7 @@ typedef struct {
/* PRIVATE CONTEXT (set by decoder) */
const char *error_msg;
} JPEG2KDECODESTATE;
/* -------------------------------------------------------------------- */

View File

@ -338,7 +338,7 @@ j2ku_srgb_rgb(opj_image_t *in, const JPEG2KTILEINFO *tileinfo,
UINT8 *row = (UINT8 *)im->image[y0 + y] + x0 * 4;
for (n = 0; n < 3; ++n)
data[n] = &cdata[n][csiz[n] * y * w];
for (x = 0; x < w; ++x) {
for (n = 0; n < 3; ++n) {
UINT32 word = 0;
@ -391,7 +391,7 @@ j2ku_sycc_rgb(opj_image_t *in, const JPEG2KTILEINFO *tileinfo,
UINT8 *row_start = row;
for (n = 0; n < 3; ++n)
data[n] = &cdata[n][csiz[n] * y * w];
for (x = 0; x < w; ++x) {
for (n = 0; n < 3; ++n) {
UINT32 word = 0;
@ -445,7 +445,7 @@ j2ku_srgba_rgba(opj_image_t *in, const JPEG2KTILEINFO *tileinfo,
UINT8 *row = (UINT8 *)im->image[y0 + y] + x0 * 4;
for (n = 0; n < 4; ++n)
data[n] = &cdata[n][csiz[n] * y * w];
for (x = 0; x < w; ++x) {
for (n = 0; n < 4; ++n) {
UINT32 word = 0;
@ -497,7 +497,7 @@ j2ku_sycca_rgba(opj_image_t *in, const JPEG2KTILEINFO *tileinfo,
UINT8 *row_start = row;
for (n = 0; n < 4; ++n)
data[n] = &cdata[n][csiz[n] * y * w];
for (x = 0; x < w; ++x) {
for (n = 0; n < 4; ++n) {
UINT32 word = 0;
@ -561,13 +561,13 @@ j2k_decode_entry(Imaging im, ImagingCodecState state)
unsigned n;
stream = opj_stream_create(BUFFER_SIZE, OPJ_TRUE);
if (!stream) {
state->errcode = IMAGING_CODEC_BROKEN;
state->state = J2K_STATE_FAILED;
goto quick_exit;
}
opj_stream_set_read_function(stream, j2k_read);
opj_stream_set_skip_function(stream, j2k_skip);
@ -589,13 +589,13 @@ j2k_decode_entry(Imaging im, ImagingCodecState state)
/* Setup decompression context */
context->error_msg = NULL;
opj_set_default_decoder_parameters(&params);
params.cp_reduce = context->reduce;
params.cp_layer = context->layers;
codec = opj_create_decompress(context->format);
if (!codec) {
state->errcode = IMAGING_CODEC_BROKEN;
state->state = J2K_STATE_FAILED;
@ -618,7 +618,7 @@ j2k_decode_entry(Imaging im, ImagingCodecState state)
state->state = J2K_STATE_FAILED;
goto quick_exit;
}
for (n = 1; n < image->numcomps; ++n) {
if (image->comps[n].dx != 1 || image->comps[n].dy != 1) {
state->errcode = IMAGING_CODEC_BROKEN;
@ -626,7 +626,7 @@ j2k_decode_entry(Imaging im, ImagingCodecState state)
goto quick_exit;
}
}
/*
Colorspace Number of components PIL mode
------------------------------------------------------
@ -635,22 +635,22 @@ j2k_decode_entry(Imaging im, ImagingCodecState state)
gray 1 L or I
gray 2 LA
YCC 3 YCbCr
If colorspace is unspecified, we assume:
Number of components Colorspace
-----------------------------------------
1 gray
2 gray (+ alpha)
3 sRGB
4 sRGB (+ alpha)
*/
/* Find the correct unpacker */
color_space = image->color_space;
if (color_space == OPJ_CLRSPC_UNSPECIFIED) {
switch (image->numcomps) {
case 1: case 2: color_space = OPJ_CLRSPC_GRAY; break;
@ -756,7 +756,7 @@ j2k_decode_entry(Imaging im, ImagingCodecState state)
context->pfile = NULL;
}
}
quick_exit:
if (codec)
opj_destroy_codec(codec);
@ -783,7 +783,7 @@ ImagingJpeg2KDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
if (state->state == J2K_STATE_START) {
state->state = J2K_STATE_DECODING;
return j2k_decode_entry(im, state);
}
@ -806,7 +806,7 @@ ImagingJpeg2KDecodeCleanup(ImagingCodecState state) {
if (context->error_msg) {
free ((void *)context->error_msg);
}
context->error_msg = NULL;
return -1;

View File

@ -70,11 +70,11 @@ j2k_skip(OPJ_OFF_T p_nb_bytes, void *p_user_data)
if (!buffer) {
return (OPJ_OFF_T)-1;
}
result = _imaging_write_pyFd(state->fd, buffer, p_nb_bytes);
free(buffer);
return result ? result : p_nb_bytes;
}
@ -368,7 +368,7 @@ j2k_encode_entry(Imaging im, ImagingCodecState state)
context->error_msg = NULL;
opj_set_default_encoder_parameters(&params);
params.image_offset_x0 = context->offset_x;
params.image_offset_y0 = context->offset_y;

View File

@ -388,7 +388,7 @@ packI16N_I16B(UINT8* out, const UINT8* in, int pixels){
C16B;
out += 2; tmp += 2;
}
}
static void
packI16N_I16(UINT8* out, const UINT8* in, int pixels){

View File

@ -1114,7 +1114,7 @@ k_means(Pixel *pixelData,
goto error_1;
}
}
/* this is enough of a check, since the multiplication n*size is done above */
if (nPaletteEntries > UINT32_MAX / nPaletteEntries) {
goto error_1;
@ -1425,7 +1425,7 @@ quantize2(Pixel *pixelData,
uint32_t *qp;
uint32_t *avgDist;
uint32_t **avgDistSortKey;
/* malloc check ok, using calloc */
p=calloc(nQuantPixels, sizeof(Pixel));
if (!p) return 0;

View File

@ -137,7 +137,7 @@ int ImagingQuantHeapTop(Heap *h,void **r) {
Heap *ImagingQuantHeapNew(HeapCmpFunc cf) {
Heap *h;
/* malloc check ok, small constant allocation */
h=malloc(sizeof(Heap));
if (!h) return NULL;

View File

@ -59,7 +59,7 @@ ImagingRankFilter(Imaging im, int size, int rank)
if (!(size & 1))
return (Imaging) ImagingError_ValueError("bad filter size");
/* malloc check ok, for overflow in the define below */
if (size > INT_MAX / size ||
size > INT_MAX / (size * sizeof(FLOAT32))) {

View File

@ -81,13 +81,13 @@ static struct filter LANCZOS = { lanczos_filter, 3.0 };
UINT8 _lookups[512] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
@ -105,13 +105,13 @@ UINT8 _lookups[512] = {
208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
};
@ -249,7 +249,7 @@ ImagingResampleHorizontal_8bpc(Imaging imIn, int xsize, struct filter *filterp)
}
kmax = normalize_coeffs_8bpc(xsize, kmax, prekk, &kk);
free(prekk);
free(prekk);
if ( ! kmax) {
free(xbounds);
return (Imaging) ImagingError_MemoryError();
@ -354,7 +354,7 @@ ImagingResampleVertical_8bpc(Imaging imIn, int ysize, struct filter *filterp)
}
kmax = normalize_coeffs_8bpc(ysize, kmax, prekk, &kk);
free(prekk);
free(prekk);
if ( ! kmax) {
free(xbounds);
return (Imaging) ImagingError_MemoryError();

View File

@ -906,7 +906,7 @@ unpackI16N_I16B(UINT8* out, const UINT8* in, int pixels){
C16B;
in += 2; tmp += 2;
}
}
static void
unpackI16N_I16(UINT8* out, const UINT8* in, int pixels){
@ -921,7 +921,7 @@ unpackI16N_I16(UINT8* out, const UINT8* in, int pixels){
static void
unpackI12_I16(UINT8* out, const UINT8* in, int pixels){
/* Fillorder 1/MSB -> LittleEndian, for 12bit integer greyscale tiffs.
According to the TIFF spec:
FillOrder = 2 should be used only when BitsPerSample = 1 and
@ -958,7 +958,7 @@ unpackI12_I16(UINT8* out, const UINT8* in, int pixels){
#else
out16[1] = pixel;
#endif
in += 3; out16 += 2; out+=4;
}
if (i == pixels-1) {

View File

@ -42,7 +42,7 @@ ImagingZipEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
state->errcode = IMAGING_CODEC_MEMORY;
return -1;
}
/* Expand standard buffer to make room for the filter selector,
and allocate filter buffers */
free(state->buffer);

View File

@ -20,11 +20,11 @@ _imaging_read_pyFd(PyObject *fd, char* dest, Py_ssize_t bytes)
if (bytes_result == -1) {
goto err;
}
if (length > bytes) {
goto err;
}
memcpy(dest, buffer, length);
Py_DECREF(result);
@ -33,7 +33,7 @@ _imaging_read_pyFd(PyObject *fd, char* dest, Py_ssize_t bytes)
err:
Py_DECREF(result);
return -1;
}
Py_ssize_t
@ -42,7 +42,7 @@ _imaging_write_pyFd(PyObject *fd, char* src, Py_ssize_t bytes)
PyObject *result;
PyObject *byteObj;
byteObj = PyBytes_FromStringAndSize(src, bytes);
result = PyObject_CallMethod(fd, "write", "O", byteObj);
@ -50,14 +50,14 @@ _imaging_write_pyFd(PyObject *fd, char* src, Py_ssize_t bytes)
Py_DECREF(result);
return bytes;
}
int
_imaging_seek_pyFd(PyObject *fd, Py_ssize_t offset, int whence)
{
PyObject *result;
result = PyObject_CallMethod(fd, "seek", "ni", offset, whence);
Py_DECREF(result);
@ -70,7 +70,7 @@ _imaging_tell_pyFd(PyObject *fd)
{
PyObject *result;
Py_ssize_t location;
result = PyObject_CallMethod(fd, "tell", NULL);
location = PyInt_AsSsize_t(result);

View File

@ -64,7 +64,7 @@ def install():
return
if fl_win or fl_cygwin:
#windows barfs on multiprocessing installs
# windows barfs on multiprocessing installs
print("Single threaded build for windows")
return

View File

@ -153,7 +153,7 @@ if __name__ == '__main__':
op = "bdist_wininst --user-access-control=auto"
elif '--wheel' in opts:
op = "bdist_wheel"
if 'PYTHON' in os.environ:
run_one(op)
else: