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

View File

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

View File

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

View File

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

View File

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

View File

@ -32,6 +32,7 @@ for r in range(8):
for b in range(4): for b in range(4):
PALETTE = PALETTE + (o8((r*255)//7)+o8((g*255)//7)+o8((b*255)//3)) PALETTE = PALETTE + (o8((r*255)//7)+o8((g*255)//7)+o8((b*255)//3))
def _accept(prefix): def _accept(prefix):
return prefix[:6] == _MAGIC 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. # 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 # PyPies 1.6, 2.0 do not have tkinter built in. PyPy3-2.3.1 gives an
# OSError trying to import tkinter. Otherwise: # 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__ TKINTER_LIB = tk.tklib_cffi.__file__
except AttributeError: except AttributeError:
# PyPy3 2.4, 2.1-beta1; PyPy 2.5.1, 2.5.0, 2.4.0, 2.3, 2.2, 2.1 # 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 pip install coverage nose
If you're using Python 2.6, there's one additional dependency:: If you're using Python 2.6, there's one additional dependency::
pip install unittest2 pip install unittest2
Execution Execution

View File

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

View File

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

View File

@ -472,11 +472,11 @@ class TestFileTiff(PillowTestCase):
tmpfile = self.tempfile("temp.tif") tmpfile = self.tempfile("temp.tif")
im.save(tmpfile) im.save(tmpfile)
reloaded = Image.open(tmpfile) reloaded = Image.open(tmpfile)
self.assert_image_equal(im, reloaded) self.assert_image_equal(im, reloaded)
if __name__ == '__main__': if __name__ == '__main__':
unittest.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((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), color)
rectangle((size[0] // 2, size[1] // 2, size[0], size[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): def make_sample(self, data, size):
"""Restores a sample image from given data string which contains """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 # Helper function to reduce precision of tuples of floats
# recursively and then check equality. # recursively and then check equality.
power = 10 ** digits power = 10 ** digits
def truncate_tuple(tuple_or_float): def truncate_tuple(tuple_or_float):
return tuple( return tuple(
truncate_tuple(val) if isinstance(val, tuple) truncate_tuple(val) if isinstance(val, tuple)

View File

@ -81,7 +81,7 @@ class TestImageOps(PillowTestCase):
def test_scale(self): def test_scale(self):
# Test the scaling function # Test the scaling function
i = hopper("L").resize((50, 50)) i = hopper("L").resize((50, 50))
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
ImageOps.scale(i, -1) 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 # 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. # size and shape of the array. This causes failures in several tests.
SKIP_NUMPY_ON_PYPY = hasattr(sys, 'pypy_version_info') and ( 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): class TestNumpy(PillowTestCase):
@ -137,14 +138,14 @@ class TestNumpy(PillowTestCase):
numpy.testing.assert_array_equal(arr, arr_back) numpy.testing.assert_array_equal(arr, arr_back)
def test_save_tiff_uint16(self): 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 pixel_value = 0x1234
a = numpy.array([pixel_value] * TEST_IMAGE_SIZE[0] * TEST_IMAGE_SIZE[1], dtype=numpy.uint16) a = numpy.array([pixel_value] * TEST_IMAGE_SIZE[0] * TEST_IMAGE_SIZE[1], dtype=numpy.uint16)
a.shape = TEST_IMAGE_SIZE a.shape = TEST_IMAGE_SIZE
img = Image.fromarray(a) img = Image.fromarray(a)
img_px = img.load() 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") @unittest.skipIf(SKIP_NUMPY_ON_PYPY, "numpy.array(Image) is flaky on PyPy")
def test_to_array(self): def test_to_array(self):

View File

@ -364,17 +364,17 @@ getbands(const char* mode)
static void* static void*
getlist(PyObject* arg, Py_ssize_t* length, const char* wrong_length, int type) 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. python sequence arg.
- the size of the returned array is in length - 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 specified in type
- sequence length is checked against the length parameter IF - sequence length is checked against the length parameter IF
an error parameter is passed in wrong_length 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; int itemp;
double dtemp; double dtemp;
void* list; void* list;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -282,7 +282,7 @@ Building on Linux
^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
If you didn't build Python from source, make sure you have Python's If you didn't build Python from source, make sure you have Python's
development libraries installed. development libraries installed.
In Debian or Ubuntu:: In Debian or Ubuntu::
@ -295,10 +295,10 @@ Or for Python 3::
In Fedora, the command is:: In Fedora, the command is::
$ sudo dnf install python-devel redhat-rpm-config $ sudo dnf install python-devel redhat-rpm-config
Or for Python 3:: 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. .. 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. changes it.
.. code-block:: python .. code-block:: python
from PIL import Image from PIL import Image
im = Image.open('hopper.jpg') im = Image.open('hopper.jpg')
px = im.load() px = im.load()
@ -28,7 +28,7 @@ Results in the following::
(23, 24, 68) (23, 24, 68)
(0, 0, 0) (0, 0, 0)
:py:class:`PixelAccess` Class :py:class:`PixelAccess` Class
----------------------------------- -----------------------------------
@ -43,9 +43,9 @@ Results in the following::
:param xy: The pixel coordinate, given as (x, y). :param xy: The pixel coordinate, given as (x, y).
:param value: The pixel value. :param value: The pixel value.
.. method:: __getitem__(self, xy): .. method:: __getitem__(self, xy):
Returns the pixel at x,y. The pixel is returned as a single Returns the pixel at x,y. The pixel is returned as a single
value for single band images or a tuple for multiple band value for single band images or a tuple for multiple band
images images
@ -62,9 +62,9 @@ Results in the following::
:param xy: The pixel coordinate, given as (x, y). :param xy: The pixel coordinate, given as (x, y).
:param value: The pixel value. :param value: The pixel value.
.. method:: getpixel(self, xy): .. method:: getpixel(self, xy):
Returns the pixel at x,y. The pixel is returned as a single Returns the pixel at x,y. The pixel is returned as a single
value for single band images or a tuple for multiple band value for single band images or a tuple for multiple band
images images

View File

@ -16,7 +16,7 @@ Example
The following script loads an image, accesses one pixel from it, then changes it. The following script loads an image, accesses one pixel from it, then changes it.
.. code-block:: python .. code-block:: python
from PIL import Image from PIL import Image
im = Image.open('hopper.jpg') im = Image.open('hopper.jpg')
px = im.load() px = im.load()
@ -29,7 +29,7 @@ Results in the following::
(23, 24, 68) (23, 24, 68)
(0, 0, 0) (0, 0, 0)
:py:class:`PyAccess` Class :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 type: Integer type from :py:attr:`PIL.TiffTags.TYPES`
:param length: Array length: 0 == variable, 1 == single value, n = fixed :param length: Array length: 0 == variable, 1 == single value, n = fixed
:param enum: Dict of name:integer value options for an enumeration :param enum: Dict of name:integer value options for an enumeration
.. method:: cvt_enum(self, value) .. method:: cvt_enum(self, value)
:param value: The enumerated value name :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, status = encoder->encode(encoder->im, &encoder->state,
(UINT8*) NULL, 0); (UINT8*) NULL, 0);
result = Py_BuildValue("ii", status, encoder->state.errcode); result = Py_BuildValue("ii", status, encoder->state.errcode);
return result; return result;
@ -291,7 +291,7 @@ _setfd(ImagingEncoderObject* encoder, PyObject* args)
Py_XINCREF(fd); Py_XINCREF(fd);
state->fd = fd; state->fd = fd;
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }

View File

@ -294,7 +294,7 @@ rgb2hsv(UINT8* out, const UINT8* in, int xsize)
r = in[0]; r = in[0];
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;
@ -324,7 +324,7 @@ rgb2hsv(UINT8* out, const UINT8* in, int xsize)
*out++ = uh; *out++ = uh;
*out++ = us; *out++ = us;
*out++ = uv; *out++ = uv;
} }
*out++ = in[3]; *out++ = in[3];
} }
@ -333,18 +333,18 @@ rgb2hsv(UINT8* out, const UINT8* in, int xsize)
static void static void
hsv2rgb(UINT8* out, const UINT8* in, int xsize) hsv2rgb(UINT8* out, const UINT8* in, int xsize)
{ // following colorsys.py { // following colorsys.py
int p,q,t; int p,q,t;
UINT8 up,uq,ut; UINT8 up,uq,ut;
int i, x; int i, x;
float f, fs; float f, fs;
UINT8 h,s,v; UINT8 h,s,v;
for (x = 0; x < xsize; x++, in += 4) { for (x = 0; x < xsize; x++, in += 4) {
h = in[0]; h = in[0];
s = in[1]; s = in[1];
v = in[2]; v = in[2];
if (s==0){ if (s==0){
*out++ = v; *out++ = v;
*out++ = v; *out++ = v;
@ -360,7 +360,7 @@ hsv2rgb(UINT8* out, const UINT8* in, int xsize)
up = (UINT8)CLIP(p); up = (UINT8)CLIP(p);
uq = (UINT8)CLIP(q); uq = (UINT8)CLIP(q);
ut = (UINT8)CLIP(t); ut = (UINT8)CLIP(t);
switch (i%6) { switch (i%6) {
case 0: case 0:
*out++ = v; *out++ = v;
@ -392,7 +392,7 @@ hsv2rgb(UINT8* out, const UINT8* in, int xsize)
*out++ = up; *out++ = up;
*out++ = uq; *out++ = uq;
break; break;
} }
} }
*out++ = in[3]; *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 * 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)
{ {
@ -502,7 +502,7 @@ rgbT2rgba(UINT8* out, int xsize, int r, int g, int b)
} }
} }
} }
/* ---------------- */ /* ---------------- */
/* CMYK conversions */ /* CMYK conversions */
@ -1383,7 +1383,7 @@ ImagingConvertTransparent(Imaging imIn, const char *mode,
if (!imIn){ if (!imIn){
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))

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -81,13 +81,13 @@ static struct filter LANCZOS = { lanczos_filter, 3.0 };
UINT8 _lookups[512] = { 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, 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, 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, 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, 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, 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, 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 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); kmax = normalize_coeffs_8bpc(xsize, kmax, prekk, &kk);
free(prekk); free(prekk);
if ( ! kmax) { if ( ! kmax) {
free(xbounds); free(xbounds);
return (Imaging) ImagingError_MemoryError(); 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); kmax = normalize_coeffs_8bpc(ysize, kmax, prekk, &kk);
free(prekk); free(prekk);
if ( ! kmax) { if ( ! kmax) {
free(xbounds); free(xbounds);
return (Imaging) ImagingError_MemoryError(); return (Imaging) ImagingError_MemoryError();

View File

@ -906,7 +906,7 @@ unpackI16N_I16B(UINT8* out, const UINT8* in, int pixels){
C16B; C16B;
in += 2; tmp += 2; in += 2; tmp += 2;
} }
} }
static void static void
unpackI16N_I16(UINT8* out, const UINT8* in, int pixels){ unpackI16N_I16(UINT8* out, const UINT8* in, int pixels){
@ -921,7 +921,7 @@ 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
@ -958,7 +958,7 @@ unpackI12_I16(UINT8* out, const UINT8* in, int pixels){
#else #else
out16[1] = pixel; out16[1] = pixel;
#endif #endif
in += 3; out16 += 2; out+=4; in += 3; out16 += 2; out+=4;
} }
if (i == pixels-1) { if (i == pixels-1) {

View File

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

View File

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

View File

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

View File

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