mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Merge branch 'master' into rotation-pixel-center
This commit is contained in:
commit
993e49c0be
24
CHANGES.rst
24
CHANGES.rst
|
@ -4,6 +4,30 @@ Changelog (Pillow)
|
|||
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
|
||||
[homm]
|
||||
|
||||
|
|
|
@ -111,5 +111,3 @@ class FontFile(object):
|
|||
else:
|
||||
puti16(fp, m[0] + m[1] + m[2])
|
||||
fp.close()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -1575,7 +1575,7 @@ class Image(object):
|
|||
|
||||
# Fast paths regardless of filter
|
||||
if angle == 0:
|
||||
return self._new(self.im)
|
||||
return self.copy()
|
||||
if angle == 180:
|
||||
return self.transpose(ROTATE_180)
|
||||
if angle == 90 and expand:
|
||||
|
@ -2521,5 +2521,3 @@ def effect_noise(size, sigma):
|
|||
:param sigma: Standard deviation of noise.
|
||||
"""
|
||||
return Image()._new(core.effect_noise(size, sigma))
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -969,5 +969,3 @@ if __name__ == "__main__":
|
|||
print(doc)
|
||||
except (AttributeError, TypeError):
|
||||
pass
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -50,8 +50,8 @@ class ImageDraw(object):
|
|||
"""
|
||||
Create a drawing instance.
|
||||
|
||||
@param im The image to draw in.
|
||||
@param mode Optional mode to use for color values. For RGB
|
||||
:param im: The image to draw in.
|
||||
:param mode: Optional mode to use for color values. For RGB
|
||||
images, this argument can be RGB or RGBA (to blend the
|
||||
drawing into the image). For all other modes, this argument
|
||||
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.
|
||||
|
||||
@param im The image to draw in.
|
||||
@param mode Optional mode to use for color values. For RGB
|
||||
:param im: The image to draw in.
|
||||
:param mode: Optional mode to use for color values. For RGB
|
||||
images, this argument can be RGB or RGBA (to blend the
|
||||
drawing into the image). For all other modes, this argument
|
||||
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,
|
||||
based on the WCK interface.
|
||||
|
||||
@param im The image to draw in.
|
||||
@param hints An optional list of hints.
|
||||
@return A (drawing context, drawing resource factory) tuple.
|
||||
:param im: The image to draw in.
|
||||
:param hints: An optional list of hints.
|
||||
:returns: A (drawing context, drawing resource factory) tuple.
|
||||
"""
|
||||
# FIXME: this needs more work!
|
||||
# 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.
|
||||
|
||||
@param image Target image.
|
||||
@param xy Seed position (a 2-item coordinate tuple).
|
||||
@param value Fill color.
|
||||
@param border Optional border value. If given, the region consists of
|
||||
:param image: Target image.
|
||||
:param xy: Seed position (a 2-item coordinate tuple).
|
||||
:param value: Fill color.
|
||||
:param border: Optional border value. If given, the region consists of
|
||||
pixels with a color different from the border color. If not given,
|
||||
the region consists of pixels having the same color as the seed
|
||||
pixel.
|
||||
|
@ -380,5 +380,3 @@ def floodfill(image, xy, value, border=None):
|
|||
pixel[s, t] = value
|
||||
newedge.append((s, t))
|
||||
edge = newedge
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -433,5 +433,3 @@ Gc/eeW7BwPj5+QGZhANUswMAAAD//2JgqGBgYGBgqEMXlvhMPUsAAAAA//8iYDd1AAAAAP//AwDR
|
|||
w7IkEbzhVQAAAABJRU5ErkJggg==
|
||||
'''))))
|
||||
return f
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -268,5 +268,3 @@ def eval(expression, _dict={}, **kw):
|
|||
return out.im
|
||||
except AttributeError:
|
||||
return out
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -48,5 +48,3 @@ def getmode(mode):
|
|||
_modes["I;16L"] = ModeDescriptor("I;16L", "I", "L", "L")
|
||||
_modes["I;16B"] = ModeDescriptor("I;16B", "I", "L", "L")
|
||||
return _modes[mode]
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -247,5 +247,3 @@ class MorphOp(object):
|
|||
def set_lut(self, lut):
|
||||
"""Set the lut from an external source"""
|
||||
self.lut = lut
|
||||
|
||||
# End of 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):
|
||||
"""
|
||||
Deform the image.
|
||||
|
|
|
@ -58,5 +58,3 @@ class Path(object):
|
|||
|
||||
# override with C implementation
|
||||
Path = Image.core.path
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -42,10 +42,10 @@ def show(image, title=None, **options):
|
|||
"""
|
||||
Display a given image.
|
||||
|
||||
@param image An image object.
|
||||
@param title Optional title. Not all viewers can display the title.
|
||||
@param **options Additional viewer options.
|
||||
@return True if a suitable viewer was found, false otherwise.
|
||||
:param image: An image object.
|
||||
:param title: Optional title. Not all viewers can display the title.
|
||||
:param \**options: Additional viewer options.
|
||||
:returns: True if a suitable viewer was found, false otherwise.
|
||||
"""
|
||||
for viewer in _viewers:
|
||||
if viewer.show(image, title=title, **options):
|
||||
|
@ -174,5 +174,3 @@ else:
|
|||
if __name__ == "__main__":
|
||||
# usage: python ImageShow.py imagefile [title]
|
||||
print(show(Image.open(sys.argv[1]), *sys.argv[2:]))
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -286,5 +286,3 @@ def _show(image, title):
|
|||
if title:
|
||||
top.title(title)
|
||||
UI(top, image).pack()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -41,10 +41,10 @@ class AffineTransform(Transform):
|
|||
This function can be used to scale, translate, rotate, and shear the
|
||||
original image.
|
||||
|
||||
@def AffineTransform(matrix)
|
||||
@param matrix A 6-tuple (a, b, c, d, e, f) containing the first two rows
|
||||
See :py:meth:`~PIL.Image.Image.transform`
|
||||
|
||||
:param matrix: A 6-tuple (a, b, c, d, e, f) containing the first two rows
|
||||
from an affine transform matrix.
|
||||
@see Image#Image.transform
|
||||
"""
|
||||
method = Image.AFFINE
|
||||
|
||||
|
@ -62,10 +62,10 @@ class ExtentTransform(Transform):
|
|||
rectangle in the current image. It is slightly slower than crop, but about
|
||||
as fast as a corresponding resize operation.
|
||||
|
||||
@def ExtentTransform(bbox)
|
||||
@param bbox A 4-tuple (x0, y0, x1, y1) which specifies two points in the
|
||||
See :py:meth:`~PIL.Image.Image.transform`
|
||||
|
||||
:param bbox: A 4-tuple (x0, y0, x1, y1) which specifies two points in the
|
||||
input image's coordinate system.
|
||||
@see Image#Image.transform
|
||||
"""
|
||||
method = Image.EXTENT
|
||||
|
||||
|
@ -77,11 +77,11 @@ class QuadTransform(Transform):
|
|||
Maps a quadrilateral (a region defined by four corners) from the image to a
|
||||
rectangle of the given size.
|
||||
|
||||
@def QuadTransform(xy)
|
||||
@param xy An 8-tuple (x0, y0, x1, y1, x2, y2, y3, y3) which contain the
|
||||
See :py:meth:`~PIL.Image.Image.transform`
|
||||
|
||||
: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
|
||||
source quadrilateral.
|
||||
@see Image#Image.transform
|
||||
"""
|
||||
method = Image.QUAD
|
||||
|
||||
|
@ -91,10 +91,8 @@ class MeshTransform(Transform):
|
|||
Define a mesh image transform. A mesh transform consists of one or more
|
||||
individual quad transforms.
|
||||
|
||||
@def MeshTransform(data)
|
||||
@param data A list of (bbox, quad) tuples.
|
||||
@see Image#Image.transform
|
||||
See :py:meth:`~PIL.Image.Image.transform`
|
||||
|
||||
:param data: A list of (bbox, quad) tuples.
|
||||
"""
|
||||
method = Image.MESH
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -233,5 +233,3 @@ class ImageWindow(Window):
|
|||
|
||||
def ui_handle_repair(self, dc, x0, y0, x1, y1):
|
||||
self.image.draw(dc, (x0, y0, x1, y1))
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -317,5 +317,3 @@ def new(img, readonly=False):
|
|||
logger.debug("PyAccess Not Implemented: %s", img.mode)
|
||||
return None
|
||||
return access_type(img, readonly)
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -85,5 +85,3 @@ Image.register_extension(SgiImageFile.format, ".bw")
|
|||
Image.register_extension(SgiImageFile.format, ".rgb")
|
||||
Image.register_extension(SgiImageFile.format, ".rgba")
|
||||
Image.register_extension(SgiImageFile.format, ".sgi")
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
VERSION = '1.1.7' # PIL version
|
||||
PILLOW_VERSION = '3.4.0.dev0' # Pillow
|
||||
|
||||
__version__ = PILLOW_VERSION
|
||||
|
||||
_plugins = ['BmpImagePlugin',
|
||||
'BufrStubImagePlugin',
|
||||
'CurImagePlugin',
|
||||
|
|
|
@ -72,5 +72,3 @@ def o16be(i):
|
|||
|
||||
def o32be(i):
|
||||
return pack(">I", i)
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -14,5 +14,3 @@ if __name__ == "__main__":
|
|||
print("''')), Image.open(BytesIO(base64.decodestring(b'''")
|
||||
base64.encode(open(font + ".pbm", "rb"), sys.stdout)
|
||||
print("'''))))")
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -56,5 +56,3 @@ class BenchCffiAccess(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from PIL import Image
|
||||
from helper import unittest, PillowTestCase
|
||||
|
||||
|
||||
class TestJ2kEncodeOverflow(PillowTestCase):
|
||||
def test_j2k_overflow(self):
|
||||
|
||||
|
@ -12,7 +13,7 @@ class TestJ2kEncodeOverflow(PillowTestCase):
|
|||
except IOError as err:
|
||||
self.assertTrue(True, "IOError is expected")
|
||||
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__':
|
||||
unittest.main()
|
||||
|
|
|
@ -35,5 +35,3 @@ class LargeMemoryTest(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -41,5 +41,3 @@ class LargeMemoryNumpyTest(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -238,5 +238,3 @@ if sys.platform == 'win32':
|
|||
IMCONVERT = os.path.join(IMCONVERT, 'convert.exe')
|
||||
else:
|
||||
IMCONVERT = 'convert'
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -28,5 +28,3 @@ class TestSanity(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -25,5 +25,3 @@ class TestBinary(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -90,5 +90,3 @@ class TestBmpReference(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -233,5 +233,3 @@ class TestBoxBlur(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -41,5 +41,3 @@ class TestDecompressionBomb(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -31,5 +31,3 @@ class TestFeatures(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -77,8 +77,5 @@ class TestFileBmp(PillowTestCase):
|
|||
self.assert_image_equal(im, target)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -15,5 +15,3 @@ class TestFileBufrStub(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -32,5 +32,3 @@ class TestFileCur(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -63,5 +63,3 @@ class TestFileDcx(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -95,5 +95,3 @@ class TestFileDds(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -267,5 +267,3 @@ class TestFileEps(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -15,5 +15,3 @@ class TestFileFitsStub(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -44,5 +44,3 @@ class TestFileFli(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -19,5 +19,3 @@ class TestFileFpx(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -20,5 +20,3 @@ class TestFileGbr(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -309,5 +309,3 @@ class TestFileGif(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -123,5 +123,3 @@ class TestImage(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -32,5 +32,3 @@ class TestImage(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -15,5 +15,3 @@ class TestFileGribStub(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -15,5 +15,3 @@ class TestFileHdf5Stub(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -86,5 +86,3 @@ class TestFileIcns(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -52,5 +52,3 @@ class TestFileIco(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -49,5 +49,3 @@ class TestFileIm(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -63,5 +63,3 @@ class TestFileIptc(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -453,5 +453,3 @@ class TestFileJpeg(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -185,5 +185,3 @@ class TestFileJpeg2k(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -170,7 +170,8 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
'RowsPerStrip',
|
||||
'StripOffsets']
|
||||
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):
|
||||
# these should not crash. Seriously dummy data, most of it doesn't make
|
||||
|
@ -183,7 +184,8 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
in TiffTags.LIBTIFF_CORE]
|
||||
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')
|
||||
for tag in im.tag_v2.keys():
|
||||
try:
|
||||
|
@ -422,8 +424,8 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
def test_gray_semibyte_per_pixel(self):
|
||||
test_files = (
|
||||
(
|
||||
24.8,#epsilon
|
||||
(#group
|
||||
24.8, # epsilon
|
||||
( # group
|
||||
"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/hopper2R.tif",
|
||||
|
@ -431,8 +433,8 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
)
|
||||
),
|
||||
(
|
||||
7.3,#epsilon
|
||||
(#group
|
||||
7.3, # epsilon
|
||||
( # group
|
||||
"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/hopper4R.tif",
|
||||
|
@ -504,8 +506,5 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
im.save(outfile)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -50,5 +50,3 @@ class TestFileLibTiffSmall(LibTiffTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -15,5 +15,3 @@ class TestFileMcIdas(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -19,5 +19,3 @@ class TestFileMic(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -141,5 +141,3 @@ class TestFileMpo(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -44,5 +44,3 @@ class TestFileMsp(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -56,5 +56,3 @@ class TestFilePalm(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from helper import unittest, PillowTestCase, hopper
|
||||
|
||||
from PIL import Image, PcxImagePlugin
|
||||
from PIL import Image, ImageFile, PcxImagePlugin
|
||||
|
||||
|
||||
class TestFilePcx(PillowTestCase):
|
||||
|
@ -48,8 +48,84 @@ class TestFilePcx(PillowTestCase):
|
|||
# Make sure all pixels are either 0 or 255.
|
||||
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__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -77,5 +77,3 @@ class TestFilePdf(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -313,7 +313,7 @@ class TestFilePng(PillowTestCase):
|
|||
# -14: malformed chunk
|
||||
|
||||
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]
|
||||
|
||||
im = Image.open(BytesIO(test_file))
|
||||
|
@ -347,7 +347,6 @@ class TestFilePng(PillowTestCase):
|
|||
finally:
|
||||
ImageFile.LOAD_TRUNCATED_IMAGES = False
|
||||
|
||||
|
||||
def test_roundtrip_dpi(self):
|
||||
# Check dpi roundtripping
|
||||
|
||||
|
@ -502,5 +501,3 @@ class TestFilePng(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -46,5 +46,3 @@ class TestFilePpm(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -47,5 +47,3 @@ class TestImagePsd(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -42,5 +42,3 @@ class TestFileSgi(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -100,5 +100,3 @@ class TestImageSpider(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -23,5 +23,3 @@ class TestFileSun(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -34,5 +34,3 @@ class TestFileTar(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -473,5 +473,3 @@ class TestFileTiff(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -211,5 +211,3 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -80,5 +80,3 @@ class TestFileWebp(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -93,5 +93,3 @@ class TestFileWebpAlpha(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -39,5 +39,3 @@ class TestFileWebpLossless(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -110,5 +110,3 @@ class TestFileWebpMetadata(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -64,5 +64,3 @@ class TestFileXbm(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -38,5 +38,3 @@ class TestFileXpm(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -22,5 +22,3 @@ class TestFontBdf(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -64,5 +64,3 @@ class TestFontPcf(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -166,5 +166,3 @@ class TestFormatHSV(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -44,5 +44,3 @@ class TestFormatLab(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -239,5 +239,3 @@ class TestImage(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -105,6 +105,7 @@ class TestCffiPutPixel(TestImagePutPixel):
|
|||
def setUp(self):
|
||||
try:
|
||||
import cffi
|
||||
assert cffi # silence warning
|
||||
except ImportError:
|
||||
self.skipTest("No cffi")
|
||||
|
||||
|
@ -115,6 +116,7 @@ class TestCffiGetPixel(TestImageGetPixel):
|
|||
def setUp(self):
|
||||
try:
|
||||
import cffi
|
||||
assert cffi # silence warning
|
||||
except ImportError:
|
||||
self.skipTest("No cffi")
|
||||
|
||||
|
@ -125,6 +127,7 @@ class TestCffi(AccessTest):
|
|||
def setUp(self):
|
||||
try:
|
||||
import cffi
|
||||
assert cffi # silence warning
|
||||
except ImportError:
|
||||
self.skipTest("No cffi")
|
||||
|
||||
|
|
|
@ -44,5 +44,3 @@ class TestImageArray(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -135,5 +135,3 @@ class TestImageConvert(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -35,5 +35,3 @@ class TestImageCopy(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -69,5 +69,3 @@ class TestImageCrop(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -35,5 +35,3 @@ class TestImageDraft(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -97,5 +97,3 @@ class TestImageFilter(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -14,5 +14,3 @@ class TestImageFromBytes(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -46,5 +46,3 @@ class TestFromQImage(PillowQtTestCase, PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -30,5 +30,3 @@ class TestFromQPixmap(PillowQPixmapTestCase, PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -22,5 +22,3 @@ class TestImageGetBands(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -41,5 +41,3 @@ class TestImageGetBbox(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -69,5 +69,3 @@ class TestImageGetColors(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -31,5 +31,3 @@ class TestImageGetData(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -23,5 +23,3 @@ class TestImageGetExtrema(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -22,5 +22,3 @@ class TestImageGetIm(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -22,5 +22,3 @@ class TestImageGetPalette(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -34,5 +34,3 @@ class TestImageGetProjection(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -22,5 +22,3 @@ class TestImageHistogram(PillowTestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
# End of file
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user