Merge branch 'master' into rotation-pixel-center

This commit is contained in:
homm 2016-08-07 13:47:16 +03:00
commit 993e49c0be
157 changed files with 260 additions and 370 deletions

View File

@ -4,6 +4,30 @@ Changelog (Pillow)
3.4.0 (unreleased) 3.4.0 (unreleased)
------------------ ------------------
- Fix C90 compilation error for Tcl / Tk rewrite #2033
[matthew-brett]
- Fix image loading when rotating by 0 deg #2052
[homm]
- 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]
- Expose Pillow package version as PIL.__version__ #2027
[techtonik]
- Add Box and Hamming filters for resampling #1959 - Add Box and Hamming filters for resampling #1959
[homm] [homm]

View File

@ -111,5 +111,3 @@ class FontFile(object):
else: else:
puti16(fp, m[0] + m[1] + m[2]) puti16(fp, m[0] + m[1] + m[2])
fp.close() fp.close()
# End of file

View File

@ -1575,7 +1575,7 @@ class Image(object):
# Fast paths regardless of filter # Fast paths regardless of filter
if angle == 0: if angle == 0:
return self._new(self.im) return self.copy()
if angle == 180: if angle == 180:
return self.transpose(ROTATE_180) return self.transpose(ROTATE_180)
if angle == 90 and expand: if angle == 90 and expand:
@ -2521,5 +2521,3 @@ def effect_noise(size, sigma):
:param sigma: Standard deviation of noise. :param sigma: Standard deviation of noise.
""" """
return Image()._new(core.effect_noise(size, sigma)) return Image()._new(core.effect_noise(size, sigma))
# End of file

View File

@ -969,5 +969,3 @@ if __name__ == "__main__":
print(doc) print(doc)
except (AttributeError, TypeError): except (AttributeError, TypeError):
pass pass
# End of file

View File

@ -50,8 +50,8 @@ class ImageDraw(object):
""" """
Create a drawing instance. Create a drawing instance.
@param im The image to draw in. :param im: The image to draw in.
@param mode Optional mode to use for color values. For RGB :param mode: Optional mode to use for color values. For RGB
images, this argument can be RGB or RGBA (to blend the images, this argument can be RGB or RGBA (to blend the
drawing into the image). For all other modes, this argument drawing into the image). For all other modes, this argument
must be the same as the image mode. If omitted, the mode must be the same as the image mode. If omitted, the mode
@ -286,8 +286,8 @@ def Draw(im, mode=None):
""" """
A simple 2D drawing interface for PIL images. A simple 2D drawing interface for PIL images.
@param im The image to draw in. :param im: The image to draw in.
@param mode Optional mode to use for color values. For RGB :param mode: Optional mode to use for color values. For RGB
images, this argument can be RGB or RGBA (to blend the images, this argument can be RGB or RGBA (to blend the
drawing into the image). For all other modes, this argument drawing into the image). For all other modes, this argument
must be the same as the image mode. If omitted, the mode must be the same as the image mode. If omitted, the mode
@ -310,9 +310,9 @@ def getdraw(im=None, hints=None):
(Experimental) A more advanced 2D drawing interface for PIL images, (Experimental) A more advanced 2D drawing interface for PIL images,
based on the WCK interface. based on the WCK interface.
@param im The image to draw in. :param im: The image to draw in.
@param hints An optional list of hints. :param hints: An optional list of hints.
@return A (drawing context, drawing resource factory) tuple. :returns: A (drawing context, drawing resource factory) tuple.
""" """
# FIXME: this needs more work! # FIXME: this needs more work!
# FIXME: come up with a better 'hints' scheme. # FIXME: come up with a better 'hints' scheme.
@ -333,10 +333,10 @@ def floodfill(image, xy, value, border=None):
""" """
(experimental) Fills a bounded region with a given color. (experimental) Fills a bounded region with a given color.
@param image Target image. :param image: Target image.
@param xy Seed position (a 2-item coordinate tuple). :param xy: Seed position (a 2-item coordinate tuple).
@param value Fill color. :param value: Fill color.
@param border Optional border value. If given, the region consists of :param border: Optional border value. If given, the region consists of
pixels with a color different from the border color. If not given, pixels with a color different from the border color. If not given,
the region consists of pixels having the same color as the seed the region consists of pixels having the same color as the seed
pixel. pixel.
@ -380,5 +380,3 @@ def floodfill(image, xy, value, border=None):
pixel[s, t] = value pixel[s, t] = value
newedge.append((s, t)) newedge.append((s, t))
edge = newedge edge = newedge
# End of file

View File

@ -433,5 +433,3 @@ Gc/eeW7BwPj5+QGZhANUswMAAAD//2JgqGBgYGBgqEMXlvhMPUsAAAAA//8iYDd1AAAAAP//AwDR
w7IkEbzhVQAAAABJRU5ErkJggg== w7IkEbzhVQAAAABJRU5ErkJggg==
''')))) '''))))
return f return f
# End of file

View File

@ -268,5 +268,3 @@ def eval(expression, _dict={}, **kw):
return out.im return out.im
except AttributeError: except AttributeError:
return out return out
# End of file

View File

@ -48,5 +48,3 @@ def getmode(mode):
_modes["I;16L"] = ModeDescriptor("I;16L", "I", "L", "L") _modes["I;16L"] = ModeDescriptor("I;16L", "I", "L", "L")
_modes["I;16B"] = ModeDescriptor("I;16B", "I", "L", "L") _modes["I;16B"] = ModeDescriptor("I;16B", "I", "L", "L")
return _modes[mode] return _modes[mode]
# End of file

View File

@ -247,5 +247,3 @@ class MorphOp(object):
def set_lut(self, lut): def set_lut(self, lut):
"""Set the lut from an external source""" """Set the lut from an external source"""
self.lut = lut self.lut = lut
# End of file

View File

@ -178,6 +178,27 @@ def crop(image, border=0):
) )
def scale(image, factor, resample=Image.NEAREST):
"""
Returns a rescaled image by a specific factor given in parameter.
A factor greater than 1 expands the image, between 0 and 1 contracts the
image.
:param factor: The expansion factor, as a float.
:param resample: An optional resampling filter. Same values possible as
in the PIL.Image.resize function.
:returns: An :py:class:`~PIL.Image.Image` object.
"""
if factor == 1:
return image.copy()
elif factor <= 0:
raise ValueError("the factor must be greater than 0")
else:
size = (int(round(factor * image.width)),
int(round(factor * image.height)))
return image.resize(size, resample)
def deform(image, deformer, resample=Image.BILINEAR): def deform(image, deformer, resample=Image.BILINEAR):
""" """
Deform the image. Deform the image.

View File

@ -58,5 +58,3 @@ class Path(object):
# override with C implementation # override with C implementation
Path = Image.core.path Path = Image.core.path
# End of file

View File

@ -42,10 +42,10 @@ def show(image, title=None, **options):
""" """
Display a given image. Display a given image.
@param image An image object. :param image: An image object.
@param title Optional title. Not all viewers can display the title. :param title: Optional title. Not all viewers can display the title.
@param **options Additional viewer options. :param \**options: Additional viewer options.
@return True if a suitable viewer was found, false otherwise. :returns: True if a suitable viewer was found, false otherwise.
""" """
for viewer in _viewers: for viewer in _viewers:
if viewer.show(image, title=title, **options): if viewer.show(image, title=title, **options):
@ -174,5 +174,3 @@ else:
if __name__ == "__main__": if __name__ == "__main__":
# usage: python ImageShow.py imagefile [title] # usage: python ImageShow.py imagefile [title]
print(show(Image.open(sys.argv[1]), *sys.argv[2:])) print(show(Image.open(sys.argv[1]), *sys.argv[2:]))
# End of file

View File

@ -286,5 +286,3 @@ def _show(image, title):
if title: if title:
top.title(title) top.title(title)
UI(top, image).pack() UI(top, image).pack()
# End of file

View File

@ -41,10 +41,10 @@ class AffineTransform(Transform):
This function can be used to scale, translate, rotate, and shear the This function can be used to scale, translate, rotate, and shear the
original image. original image.
@def AffineTransform(matrix) See :py:meth:`~PIL.Image.Image.transform`
@param matrix A 6-tuple (a, b, c, d, e, f) containing the first two rows
:param matrix: A 6-tuple (a, b, c, d, e, f) containing the first two rows
from an affine transform matrix. from an affine transform matrix.
@see Image#Image.transform
""" """
method = Image.AFFINE method = Image.AFFINE
@ -62,10 +62,10 @@ class ExtentTransform(Transform):
rectangle in the current image. It is slightly slower than crop, but about rectangle in the current image. It is slightly slower than crop, but about
as fast as a corresponding resize operation. as fast as a corresponding resize operation.
@def ExtentTransform(bbox) See :py:meth:`~PIL.Image.Image.transform`
@param bbox A 4-tuple (x0, y0, x1, y1) which specifies two points in the
:param bbox: A 4-tuple (x0, y0, x1, y1) which specifies two points in the
input image's coordinate system. input image's coordinate system.
@see Image#Image.transform
""" """
method = Image.EXTENT method = Image.EXTENT
@ -77,11 +77,11 @@ class QuadTransform(Transform):
Maps a quadrilateral (a region defined by four corners) from the image to a Maps a quadrilateral (a region defined by four corners) from the image to a
rectangle of the given size. rectangle of the given size.
@def QuadTransform(xy) See :py:meth:`~PIL.Image.Image.transform`
@param xy An 8-tuple (x0, y0, x1, y1, x2, y2, y3, y3) which contain the
:param xy: An 8-tuple (x0, y0, x1, y1, x2, y2, y3, y3) which contain the
upper left, lower left, lower right, and upper right corner of the upper left, lower left, lower right, and upper right corner of the
source quadrilateral. source quadrilateral.
@see Image#Image.transform
""" """
method = Image.QUAD method = Image.QUAD
@ -91,10 +91,8 @@ class MeshTransform(Transform):
Define a mesh image transform. A mesh transform consists of one or more Define a mesh image transform. A mesh transform consists of one or more
individual quad transforms. individual quad transforms.
@def MeshTransform(data) See :py:meth:`~PIL.Image.Image.transform`
@param data A list of (bbox, quad) tuples.
@see Image#Image.transform :param data: A list of (bbox, quad) tuples.
""" """
method = Image.MESH method = Image.MESH
# End of file

View File

@ -233,5 +233,3 @@ class ImageWindow(Window):
def ui_handle_repair(self, dc, x0, y0, x1, y1): def ui_handle_repair(self, dc, x0, y0, x1, y1):
self.image.draw(dc, (x0, y0, x1, y1)) self.image.draw(dc, (x0, y0, x1, y1))
# End of file

View File

@ -317,5 +317,3 @@ def new(img, readonly=False):
logger.debug("PyAccess Not Implemented: %s", img.mode) logger.debug("PyAccess Not Implemented: %s", img.mode)
return None return None
return access_type(img, readonly) return access_type(img, readonly)
# End of file

View File

@ -85,5 +85,3 @@ Image.register_extension(SgiImageFile.format, ".bw")
Image.register_extension(SgiImageFile.format, ".rgb") Image.register_extension(SgiImageFile.format, ".rgb")
Image.register_extension(SgiImageFile.format, ".rgba") Image.register_extension(SgiImageFile.format, ".rgba")
Image.register_extension(SgiImageFile.format, ".sgi") Image.register_extension(SgiImageFile.format, ".sgi")
# End of file

View File

@ -14,6 +14,8 @@
VERSION = '1.1.7' # PIL version VERSION = '1.1.7' # PIL version
PILLOW_VERSION = '3.4.0.dev0' # Pillow PILLOW_VERSION = '3.4.0.dev0' # Pillow
__version__ = PILLOW_VERSION
_plugins = ['BmpImagePlugin', _plugins = ['BmpImagePlugin',
'BufrStubImagePlugin', 'BufrStubImagePlugin',
'CurImagePlugin', 'CurImagePlugin',

View File

@ -72,5 +72,3 @@ def o16be(i):
def o32be(i): def o32be(i):
return pack(">I", i) return pack(">I", i)
# End of file

View File

@ -14,5 +14,3 @@ if __name__ == "__main__":
print("''')), Image.open(BytesIO(base64.decodestring(b'''") print("''')), Image.open(BytesIO(base64.decodestring(b'''")
base64.encode(open(font + ".pbm", "rb"), sys.stdout) base64.encode(open(font + ".pbm", "rb"), sys.stdout)
print("'''))))") print("'''))))")
# End of file

View File

@ -56,5 +56,3 @@ class BenchCffiAccess(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -1,6 +1,7 @@
from PIL import Image from PIL import Image
from helper import unittest, PillowTestCase from helper import unittest, PillowTestCase
class TestJ2kEncodeOverflow(PillowTestCase): class TestJ2kEncodeOverflow(PillowTestCase):
def test_j2k_overflow(self): def test_j2k_overflow(self):
@ -12,7 +13,7 @@ class TestJ2kEncodeOverflow(PillowTestCase):
except IOError as err: except IOError as err:
self.assertTrue(True, "IOError is expected") self.assertTrue(True, "IOError is expected")
except Exception as err: except Exception as err:
self.assertTrue(False, "Expected IOError, got %s" %type(err)) self.assertTrue(False, "Expected IOError, got %s" % type(err))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -35,5 +35,3 @@ class LargeMemoryTest(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -41,5 +41,3 @@ class LargeMemoryNumpyTest(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -238,5 +238,3 @@ if sys.platform == 'win32':
IMCONVERT = os.path.join(IMCONVERT, 'convert.exe') IMCONVERT = os.path.join(IMCONVERT, 'convert.exe')
else: else:
IMCONVERT = 'convert' IMCONVERT = 'convert'
# End of file

View File

@ -28,5 +28,3 @@ class TestSanity(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -25,5 +25,3 @@ class TestBinary(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -90,5 +90,3 @@ class TestBmpReference(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -233,5 +233,3 @@ class TestBoxBlur(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -41,5 +41,3 @@ class TestDecompressionBomb(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -31,5 +31,3 @@ class TestFeatures(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -77,8 +77,5 @@ class TestFileBmp(PillowTestCase):
self.assert_image_equal(im, target) self.assert_image_equal(im, target)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -15,5 +15,3 @@ class TestFileBufrStub(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -32,5 +32,3 @@ class TestFileCur(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -63,5 +63,3 @@ class TestFileDcx(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -95,5 +95,3 @@ class TestFileDds(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -267,5 +267,3 @@ class TestFileEps(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -15,5 +15,3 @@ class TestFileFitsStub(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -44,5 +44,3 @@ class TestFileFli(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -19,5 +19,3 @@ class TestFileFpx(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -20,5 +20,3 @@ class TestFileGbr(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -309,5 +309,3 @@ class TestFileGif(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -123,5 +123,3 @@ class TestImage(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -32,5 +32,3 @@ class TestImage(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -15,5 +15,3 @@ class TestFileGribStub(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -15,5 +15,3 @@ class TestFileHdf5Stub(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -86,5 +86,3 @@ class TestFileIcns(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -52,5 +52,3 @@ class TestFileIco(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -49,5 +49,3 @@ class TestFileIm(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -63,5 +63,3 @@ class TestFileIptc(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -453,5 +453,3 @@ class TestFileJpeg(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -185,5 +185,3 @@ class TestFileJpeg2k(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -170,7 +170,8 @@ class TestFileLibTiff(LibTiffTestCase):
'RowsPerStrip', 'RowsPerStrip',
'StripOffsets'] 'StripOffsets']
for field in requested_fields: for field in requested_fields:
self.assertTrue(field in reloaded, "%s not in metadata" % field) self.assertTrue(field in reloaded,
"%s not in metadata" % field)
def test_additional_metadata(self): def test_additional_metadata(self):
# these should not crash. Seriously dummy data, most of it doesn't make # these should not crash. Seriously dummy data, most of it doesn't make
@ -183,7 +184,8 @@ class TestFileLibTiff(LibTiffTestCase):
in TiffTags.LIBTIFF_CORE] in TiffTags.LIBTIFF_CORE]
if info.type is not None) if info.type is not None)
# Exclude ones that have special meaning that we're already testing them # Exclude ones that have special meaning
# that we're already testing them
im = Image.open('Tests/images/hopper_g4.tif') im = Image.open('Tests/images/hopper_g4.tif')
for tag in im.tag_v2.keys(): for tag in im.tag_v2.keys():
try: try:
@ -422,8 +424,8 @@ class TestFileLibTiff(LibTiffTestCase):
def test_gray_semibyte_per_pixel(self): def test_gray_semibyte_per_pixel(self):
test_files = ( test_files = (
( (
24.8,#epsilon 24.8, # epsilon
(#group ( # group
"Tests/images/tiff_gray_2_4_bpp/hopper2.tif", "Tests/images/tiff_gray_2_4_bpp/hopper2.tif",
"Tests/images/tiff_gray_2_4_bpp/hopper2I.tif", "Tests/images/tiff_gray_2_4_bpp/hopper2I.tif",
"Tests/images/tiff_gray_2_4_bpp/hopper2R.tif", "Tests/images/tiff_gray_2_4_bpp/hopper2R.tif",
@ -431,8 +433,8 @@ class TestFileLibTiff(LibTiffTestCase):
) )
), ),
( (
7.3,#epsilon 7.3, # epsilon
(#group ( # group
"Tests/images/tiff_gray_2_4_bpp/hopper4.tif", "Tests/images/tiff_gray_2_4_bpp/hopper4.tif",
"Tests/images/tiff_gray_2_4_bpp/hopper4I.tif", "Tests/images/tiff_gray_2_4_bpp/hopper4I.tif",
"Tests/images/tiff_gray_2_4_bpp/hopper4R.tif", "Tests/images/tiff_gray_2_4_bpp/hopper4R.tif",
@ -504,8 +506,5 @@ class TestFileLibTiff(LibTiffTestCase):
im.save(outfile) im.save(outfile)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -50,5 +50,3 @@ class TestFileLibTiffSmall(LibTiffTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -15,5 +15,3 @@ class TestFileMcIdas(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -19,5 +19,3 @@ class TestFileMic(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -141,5 +141,3 @@ class TestFileMpo(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -44,5 +44,3 @@ class TestFileMsp(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -56,5 +56,3 @@ class TestFilePalm(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -1,6 +1,6 @@
from helper import unittest, PillowTestCase, hopper from helper import unittest, PillowTestCase, hopper
from PIL import Image, PcxImagePlugin from PIL import Image, ImageFile, PcxImagePlugin
class TestFilePcx(PillowTestCase): class TestFilePcx(PillowTestCase):
@ -48,8 +48,84 @@ class TestFilePcx(PillowTestCase):
# Make sure all pixels are either 0 or 255. # Make sure all pixels are either 0 or 255.
self.assertEqual(im.histogram()[0] + im.histogram()[255], 447*144) self.assertEqual(im.histogram()[0] + im.histogram()[255], 447*144)
def test_1px_width(self):
im = Image.new('L', (1, 256))
px = im.load()
for y in range(256):
px[0, y] = y
self._roundtrip(im)
def test_large_count(self):
im = Image.new('L', (256, 1))
px = im.load()
for x in range(256):
px[x, 0] = x // 67 * 67
self._roundtrip(im)
def _test_buffer_overflow(self, im, size=1024):
_last = ImageFile.MAXBLOCK
ImageFile.MAXBLOCK = size
try:
self._roundtrip(im)
finally:
ImageFile.MAXBLOCK = _last
def test_break_in_count_overflow(self):
im = Image.new('L', (256, 5))
px = im.load()
for y in range(4):
for x in range(256):
px[x, y] = x % 128
self._test_buffer_overflow(im)
def test_break_one_in_loop(self):
im = Image.new('L', (256, 5))
px = im.load()
for y in range(5):
for x in range(256):
px[x, y] = x % 128
self._test_buffer_overflow(im)
def test_break_many_in_loop(self):
im = Image.new('L', (256, 5))
px = im.load()
for y in range(4):
for x in range(256):
px[x, y] = x % 128
for x in range(8):
px[x, 4] = 16
self._test_buffer_overflow(im)
def test_break_one_at_end(self):
im = Image.new('L', (256, 5))
px = im.load()
for y in range(5):
for x in range(256):
px[x, y] = x % 128
px[0, 3] = 128 + 64
self._test_buffer_overflow(im)
def test_break_many_at_end(self):
im = Image.new('L', (256, 5))
px = im.load()
for y in range(5):
for x in range(256):
px[x, y] = x % 128
for x in range(4):
px[x * 2, 3] = 128 + 64
px[x + 256 - 4, 3] = 0
self._test_buffer_overflow(im)
def test_break_padding(self):
im = Image.new('L', (257, 5))
px = im.load()
for y in range(5):
for x in range(257):
px[x, y] = x % 128
for x in range(5):
px[x, 3] = 0
self._test_buffer_overflow(im)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -77,5 +77,3 @@ class TestFilePdf(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -313,7 +313,7 @@ class TestFilePng(PillowTestCase):
# -14: malformed chunk # -14: malformed chunk
for offset in (-10, -13, -14): for offset in (-10, -13, -14):
with open(TEST_PNG_FILE,'rb') as f: with open(TEST_PNG_FILE, 'rb') as f:
test_file = f.read()[:offset] test_file = f.read()[:offset]
im = Image.open(BytesIO(test_file)) im = Image.open(BytesIO(test_file))
@ -347,7 +347,6 @@ class TestFilePng(PillowTestCase):
finally: finally:
ImageFile.LOAD_TRUNCATED_IMAGES = False ImageFile.LOAD_TRUNCATED_IMAGES = False
def test_roundtrip_dpi(self): def test_roundtrip_dpi(self):
# Check dpi roundtripping # Check dpi roundtripping
@ -502,5 +501,3 @@ class TestFilePng(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -46,5 +46,3 @@ class TestFilePpm(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -47,5 +47,3 @@ class TestImagePsd(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -42,5 +42,3 @@ class TestFileSgi(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -100,5 +100,3 @@ class TestImageSpider(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -23,5 +23,3 @@ class TestFileSun(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -34,5 +34,3 @@ class TestFileTar(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -473,5 +473,3 @@ class TestFileTiff(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -211,5 +211,3 @@ class TestFileTiffMetadata(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -80,5 +80,3 @@ class TestFileWebp(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -93,5 +93,3 @@ class TestFileWebpAlpha(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -39,5 +39,3 @@ class TestFileWebpLossless(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -110,5 +110,3 @@ class TestFileWebpMetadata(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -64,5 +64,3 @@ class TestFileXbm(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -38,5 +38,3 @@ class TestFileXpm(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -22,5 +22,3 @@ class TestFontBdf(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -64,5 +64,3 @@ class TestFontPcf(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -166,5 +166,3 @@ class TestFormatHSV(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -44,5 +44,3 @@ class TestFormatLab(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -239,5 +239,3 @@ class TestImage(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -105,6 +105,7 @@ class TestCffiPutPixel(TestImagePutPixel):
def setUp(self): def setUp(self):
try: try:
import cffi import cffi
assert cffi # silence warning
except ImportError: except ImportError:
self.skipTest("No cffi") self.skipTest("No cffi")
@ -115,6 +116,7 @@ class TestCffiGetPixel(TestImageGetPixel):
def setUp(self): def setUp(self):
try: try:
import cffi import cffi
assert cffi # silence warning
except ImportError: except ImportError:
self.skipTest("No cffi") self.skipTest("No cffi")
@ -125,6 +127,7 @@ class TestCffi(AccessTest):
def setUp(self): def setUp(self):
try: try:
import cffi import cffi
assert cffi # silence warning
except ImportError: except ImportError:
self.skipTest("No cffi") self.skipTest("No cffi")

View File

@ -44,5 +44,3 @@ class TestImageArray(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -135,5 +135,3 @@ class TestImageConvert(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -35,5 +35,3 @@ class TestImageCopy(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -69,5 +69,3 @@ class TestImageCrop(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -35,5 +35,3 @@ class TestImageDraft(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -97,5 +97,3 @@ class TestImageFilter(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -14,5 +14,3 @@ class TestImageFromBytes(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -46,5 +46,3 @@ class TestFromQImage(PillowQtTestCase, PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -30,5 +30,3 @@ class TestFromQPixmap(PillowQPixmapTestCase, PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -22,5 +22,3 @@ class TestImageGetBands(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -41,5 +41,3 @@ class TestImageGetBbox(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -69,5 +69,3 @@ class TestImageGetColors(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -31,5 +31,3 @@ class TestImageGetData(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -23,5 +23,3 @@ class TestImageGetExtrema(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -22,5 +22,3 @@ class TestImageGetIm(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -22,5 +22,3 @@ class TestImageGetPalette(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -34,5 +34,3 @@ class TestImageGetProjection(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

View File

@ -22,5 +22,3 @@ class TestImageHistogram(PillowTestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# End of file

Some files were not shown because too many files have changed in this diff Show More