mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-07 13:25:24 +03:00
flake8
This commit is contained in:
parent
8de95676e0
commit
1335006cd7
|
@ -25,12 +25,14 @@ i16 = _binary.i16le
|
||||||
i32 = _binary.i32le
|
i32 = _binary.i32le
|
||||||
o8 = _binary.o8
|
o8 = _binary.o8
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# decoder
|
# decoder
|
||||||
|
|
||||||
def _accept(prefix):
|
def _accept(prefix):
|
||||||
return i16(prefix[4:6]) in [0xAF11, 0xAF12]
|
return i16(prefix[4:6]) in [0xAF11, 0xAF12]
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Image plugin for the FLI/FLC animation format. Use the <b>seek</b>
|
# Image plugin for the FLI/FLC animation format. Use the <b>seek</b>
|
||||||
# method to load individual frames.
|
# method to load individual frames.
|
||||||
|
@ -61,7 +63,7 @@ class FliImageFile(ImageFile.ImageFile):
|
||||||
self.info["duration"] = duration
|
self.info["duration"] = duration
|
||||||
|
|
||||||
# look for palette
|
# look for palette
|
||||||
palette = [(a,a,a) for a in range(256)]
|
palette = [(a, a, a) for a in range(256)]
|
||||||
|
|
||||||
s = self.fp.read(16)
|
s = self.fp.read(16)
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ class FliImageFile(ImageFile.ImageFile):
|
||||||
elif i16(s[4:6]) == 4:
|
elif i16(s[4:6]) == 4:
|
||||||
self._palette(palette, 0)
|
self._palette(palette, 0)
|
||||||
|
|
||||||
palette = [o8(r)+o8(g)+o8(b) for (r,g,b) in palette]
|
palette = [o8(r)+o8(g)+o8(b) for (r, g, b) in palette]
|
||||||
self.palette = ImagePalette.raw("RGB", b"".join(palette))
|
self.palette = ImagePalette.raw("RGB", b"".join(palette))
|
||||||
|
|
||||||
# set things up to decode first frame
|
# set things up to decode first frame
|
||||||
|
@ -124,7 +126,7 @@ class FliImageFile(ImageFile.ImageFile):
|
||||||
framesize = i32(s)
|
framesize = i32(s)
|
||||||
|
|
||||||
self.decodermaxblock = framesize
|
self.decodermaxblock = framesize
|
||||||
self.tile = [("fli", (0,0)+self.size, self.__offset, None)]
|
self.tile = [("fli", (0, 0)+self.size, self.__offset, None)]
|
||||||
|
|
||||||
self.__offset = self.__offset + framesize
|
self.__offset = self.__offset + framesize
|
||||||
|
|
||||||
|
|
|
@ -159,8 +159,8 @@ class ImImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
k, v = m.group(1, 2)
|
k, v = m.group(1, 2)
|
||||||
|
|
||||||
# Don't know if this is the correct encoding, but a decent guess
|
# Don't know if this is the correct encoding,
|
||||||
# (I guess)
|
# but a decent guess (I guess)
|
||||||
k = k.decode('latin-1', 'replace')
|
k = k.decode('latin-1', 'replace')
|
||||||
v = v.decode('latin-1', 'replace')
|
v = v.decode('latin-1', 'replace')
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import warnings
|
||||||
class DecompressionBombWarning(RuntimeWarning):
|
class DecompressionBombWarning(RuntimeWarning):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class _imaging_not_installed:
|
class _imaging_not_installed:
|
||||||
# module placeholder
|
# module placeholder
|
||||||
def __getattr__(self, id):
|
def __getattr__(self, id):
|
||||||
|
@ -847,8 +848,9 @@ class Image:
|
||||||
t = self.info['transparency']
|
t = self.info['transparency']
|
||||||
if isinstance(t, bytes):
|
if isinstance(t, bytes):
|
||||||
# Dragons. This can't be represented by a single color
|
# Dragons. This can't be represented by a single color
|
||||||
warnings.warn('Palette images with Transparency expressed ' +
|
warnings.warn('Palette images with Transparency ' +
|
||||||
' in bytes should be converted to RGBA images')
|
' expressed in bytes should be converted ' +
|
||||||
|
'to RGBA images')
|
||||||
delete_trns = True
|
delete_trns = True
|
||||||
else:
|
else:
|
||||||
# get the new transparency color.
|
# get the new transparency color.
|
||||||
|
@ -864,7 +866,7 @@ class Image:
|
||||||
# can't just retrieve the palette number, got to do it
|
# can't just retrieve the palette number, got to do it
|
||||||
# after quantization.
|
# after quantization.
|
||||||
trns_im = trns_im.convert('RGB')
|
trns_im = trns_im.convert('RGB')
|
||||||
trns = trns_im.getpixel((0,0))
|
trns = trns_im.getpixel((0, 0))
|
||||||
|
|
||||||
elif self.mode == 'P' and mode == 'RGBA':
|
elif self.mode == 'P' and mode == 'RGBA':
|
||||||
delete_trns = True
|
delete_trns = True
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
## The Python Imaging Library.
|
# The Python Imaging Library.
|
||||||
## $Id$
|
# $Id$
|
||||||
|
|
||||||
## Optional color managment support, based on Kevin Cazabon's PyCMS
|
# Optional color managment support, based on Kevin Cazabon's PyCMS
|
||||||
## library.
|
# library.
|
||||||
|
|
||||||
## History:
|
# History:
|
||||||
|
|
||||||
## 2009-03-08 fl Added to PIL.
|
# 2009-03-08 fl Added to PIL.
|
||||||
|
|
||||||
## Copyright (C) 2002-2003 Kevin Cazabon
|
# Copyright (C) 2002-2003 Kevin Cazabon
|
||||||
## Copyright (c) 2009 by Fredrik Lundh
|
# Copyright (c) 2009 by Fredrik Lundh
|
||||||
## Copyright (c) 2013 by Eric Soroos
|
# Copyright (c) 2013 by Eric Soroos
|
||||||
|
|
||||||
## See the README file for information on usage and redistribution. See
|
# See the README file for information on usage and redistribution. See
|
||||||
## below for the original description.
|
# below for the original description.
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
@ -184,6 +184,7 @@ class ImageCmsProfile:
|
||||||
|
|
||||||
return core.profile_tobytes(self.profile)
|
return core.profile_tobytes(self.profile)
|
||||||
|
|
||||||
|
|
||||||
class ImageCmsTransform(Image.ImagePointHandler):
|
class ImageCmsTransform(Image.ImagePointHandler):
|
||||||
|
|
||||||
# Transform. This can be used with the procedural API, or with the
|
# Transform. This can be used with the procedural API, or with the
|
||||||
|
@ -191,7 +192,6 @@ class ImageCmsTransform(Image.ImagePointHandler):
|
||||||
#
|
#
|
||||||
# Will return the output profile in the output.info['icc_profile'].
|
# Will return the output profile in the output.info['icc_profile'].
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, input, output, input_mode, output_mode,
|
def __init__(self, input, output, input_mode, output_mode,
|
||||||
intent=INTENT_PERCEPTUAL, proof=None,
|
intent=INTENT_PERCEPTUAL, proof=None,
|
||||||
proof_intent=INTENT_ABSOLUTE_COLORIMETRIC, flags=0):
|
proof_intent=INTENT_ABSOLUTE_COLORIMETRIC, flags=0):
|
||||||
|
|
|
@ -40,6 +40,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
warnings = None
|
warnings = None
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# A simple 2D drawing interface for PIL images.
|
# A simple 2D drawing interface for PIL images.
|
||||||
# <p>
|
# <p>
|
||||||
|
|
|
@ -162,7 +162,8 @@ class UnsharpMask(Filter):
|
||||||
See Wikipedia's entry on `digital unsharp masking`_ for an explanation of
|
See Wikipedia's entry on `digital unsharp masking`_ for an explanation of
|
||||||
the parameters.
|
the parameters.
|
||||||
|
|
||||||
.. _digital unsharp masking: https://en.wikipedia.org/wiki/Unsharp_masking#Digital_unsharp_masking
|
.. _digital unsharp masking:
|
||||||
|
https://en.wikipedia.org/wiki/Unsharp_masking#Digital_unsharp_masking
|
||||||
"""
|
"""
|
||||||
name = "UnsharpMask"
|
name = "UnsharpMask"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ try:
|
||||||
except:
|
except:
|
||||||
from PyQt4.QtGui import QImage, qRgba
|
from PyQt4.QtGui import QImage, qRgba
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# (Internal) Turns an RGB color into a Qt compatible color integer.
|
# (Internal) Turns an RGB color into a Qt compatible color integer.
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ def rgb(r, g, b, a=255):
|
||||||
# into a negative integer with the same bitpattern.
|
# into a negative integer with the same bitpattern.
|
||||||
return (qRgba(r, g, b, a) & 0xffffffff)
|
return (qRgba(r, g, b, a) & 0xffffffff)
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# An PIL image wrapper for Qt. This is a subclass of PyQt4's QImage
|
# An PIL image wrapper for Qt. This is a subclass of PyQt4's QImage
|
||||||
# class.
|
# class.
|
||||||
|
|
|
@ -26,6 +26,7 @@ from PIL import Image, ImageFile
|
||||||
|
|
||||||
field = re.compile(br"([a-z]*) ([^ \r\n]*)")
|
field = re.compile(br"([a-z]*) ([^ \r\n]*)")
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Image plugin for IM Tools images.
|
# Image plugin for IM Tools images.
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ class ImtImageFile(ImageFile.ImageFile):
|
||||||
# Quick rejection: if there's not a LF among the first
|
# Quick rejection: if there's not a LF among the first
|
||||||
# 100 bytes, this is (probably) not a text header.
|
# 100 bytes, this is (probably) not a text header.
|
||||||
|
|
||||||
if not b"\n" in self.fp.read(100):
|
if b"\n" not in self.fp.read(100):
|
||||||
raise SyntaxError("not an IM file")
|
raise SyntaxError("not an IM file")
|
||||||
self.fp.seek(0)
|
self.fp.seek(0)
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ class ImtImageFile(ImageFile.ImageFile):
|
||||||
if s == b'\x0C':
|
if s == b'\x0C':
|
||||||
|
|
||||||
# image data begins
|
# image data begins
|
||||||
self.tile = [("raw", (0,0)+self.size,
|
self.tile = [("raw", (0, 0)+self.size,
|
||||||
self.fp.tell(),
|
self.fp.tell(),
|
||||||
(self.mode, 0, 1))]
|
(self.mode, 0, 1))]
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ class ImtImageFile(ImageFile.ImageFile):
|
||||||
m = field.match(s)
|
m = field.match(s)
|
||||||
if not m:
|
if not m:
|
||||||
break
|
break
|
||||||
k, v = m.group(1,2)
|
k, v = m.group(1, 2)
|
||||||
if k == "width":
|
if k == "width":
|
||||||
xsize = int(v)
|
xsize = int(v)
|
||||||
self.size = xsize, ysize
|
self.size = xsize, ysize
|
||||||
|
|
|
@ -115,7 +115,8 @@ def APP(self, marker):
|
||||||
elif marker == 0xFFE2 and s[:4] == b"MPF\0":
|
elif marker == 0xFFE2 and s[:4] == b"MPF\0":
|
||||||
# extract MPO information
|
# extract MPO information
|
||||||
self.info["mp"] = s[4:]
|
self.info["mp"] = s[4:]
|
||||||
# offset is current location minus buffer size plus constant header size
|
# offset is current location minus buffer size
|
||||||
|
# plus constant header size
|
||||||
self.info["mpoffset"] = self.fp.tell() - n + 4
|
self.info["mpoffset"] = self.fp.tell() - n + 4
|
||||||
|
|
||||||
|
|
||||||
|
@ -321,7 +322,8 @@ class JpegImageFile(ImageFile.ImageFile):
|
||||||
rawmode = self.mode
|
rawmode = self.mode
|
||||||
if self.mode == "CMYK":
|
if self.mode == "CMYK":
|
||||||
rawmode = "CMYK;I" # assume adobe conventions
|
rawmode = "CMYK;I" # assume adobe conventions
|
||||||
self.tile = [("jpeg", (0, 0) + self.size, 0, (rawmode, ""))]
|
self.tile = [("jpeg", (0, 0) + self.size, 0,
|
||||||
|
(rawmode, ""))]
|
||||||
# self.__offset = self.fp.tell()
|
# self.__offset = self.fp.tell()
|
||||||
break
|
break
|
||||||
s = self.fp.read(1)
|
s = self.fp.read(1)
|
||||||
|
@ -472,14 +474,18 @@ def _getmp(self):
|
||||||
for entrynum in range(0, quant):
|
for entrynum in range(0, quant):
|
||||||
rawmpentry = mp[0xB002][entrynum * 16:(entrynum + 1) * 16]
|
rawmpentry = mp[0xB002][entrynum * 16:(entrynum + 1) * 16]
|
||||||
unpackedentry = unpack('{0}LLLHH'.format(endianness), rawmpentry)
|
unpackedentry = unpack('{0}LLLHH'.format(endianness), rawmpentry)
|
||||||
labels = ('Attribute', 'Size', 'DataOffset', 'EntryNo1', 'EntryNo2')
|
labels = ('Attribute', 'Size', 'DataOffset', 'EntryNo1',
|
||||||
|
'EntryNo2')
|
||||||
mpentry = dict(zip(labels, unpackedentry))
|
mpentry = dict(zip(labels, unpackedentry))
|
||||||
mpentryattr = {
|
mpentryattr = {
|
||||||
'DependentParentImageFlag': bool(mpentry['Attribute'] & (1<<31)),
|
'DependentParentImageFlag': bool(mpentry['Attribute'] &
|
||||||
'DependentChildImageFlag': bool(mpentry['Attribute'] & (1<<30)),
|
(1 << 31)),
|
||||||
'RepresentativeImageFlag': bool(mpentry['Attribute'] & (1<<29)),
|
'DependentChildImageFlag': bool(mpentry['Attribute'] &
|
||||||
'Reserved': (mpentry['Attribute'] & (3<<27)) >> 27,
|
(1 << 30)),
|
||||||
'ImageDataFormat': (mpentry['Attribute'] & (7<<24)) >> 24,
|
'RepresentativeImageFlag': bool(mpentry['Attribute'] &
|
||||||
|
(1 << 29)),
|
||||||
|
'Reserved': (mpentry['Attribute'] & (3 << 27)) >> 27,
|
||||||
|
'ImageDataFormat': (mpentry['Attribute'] & (7 << 24)) >> 24,
|
||||||
'MPType': mpentry['Attribute'] & 0x00FFFFFF
|
'MPType': mpentry['Attribute'] & 0x00FFFFFF
|
||||||
}
|
}
|
||||||
if mpentryattr['ImageDataFormat'] == 0:
|
if mpentryattr['ImageDataFormat'] == 0:
|
||||||
|
@ -530,8 +536,7 @@ zigzag_index = ( 0, 1, 5, 6, 14, 15, 27, 28,
|
||||||
21, 34, 37, 47, 50, 56, 59, 61,
|
21, 34, 37, 47, 50, 56, 59, 61,
|
||||||
35, 36, 48, 49, 57, 58, 62, 63)
|
35, 36, 48, 49, 57, 58, 62, 63)
|
||||||
|
|
||||||
samplings = {
|
samplings = {(1, 1, 1, 1, 1, 1): 0,
|
||||||
(1, 1, 1, 1, 1, 1): 0,
|
|
||||||
(2, 1, 1, 1, 1, 1): 1,
|
(2, 1, 1, 1, 1, 1): 1,
|
||||||
(2, 2, 1, 1, 1, 1): 2,
|
(2, 2, 1, 1, 1, 1): 2,
|
||||||
}
|
}
|
||||||
|
@ -589,7 +594,8 @@ def _save(im, fp, filename):
|
||||||
subsampling = 2
|
subsampling = 2
|
||||||
elif subsampling == "keep":
|
elif subsampling == "keep":
|
||||||
if im.format != "JPEG":
|
if im.format != "JPEG":
|
||||||
raise ValueError("Cannot use 'keep' when original image is not a JPEG")
|
raise ValueError(
|
||||||
|
"Cannot use 'keep' when original image is not a JPEG")
|
||||||
subsampling = get_sampling(im)
|
subsampling = get_sampling(im)
|
||||||
|
|
||||||
def validate_qtables(qtables):
|
def validate_qtables(qtables):
|
||||||
|
@ -623,7 +629,8 @@ def _save(im, fp, filename):
|
||||||
|
|
||||||
if qtables == "keep":
|
if qtables == "keep":
|
||||||
if im.format != "JPEG":
|
if im.format != "JPEG":
|
||||||
raise ValueError("Cannot use 'keep' when original image is not a JPEG")
|
raise ValueError(
|
||||||
|
"Cannot use 'keep' when original image is not a JPEG")
|
||||||
qtables = getattr(im, "quantization", None)
|
qtables = getattr(im, "quantization", None)
|
||||||
qtables = validate_qtables(qtables)
|
qtables = validate_qtables(qtables)
|
||||||
|
|
||||||
|
@ -641,7 +648,8 @@ def _save(im, fp, filename):
|
||||||
i = 1
|
i = 1
|
||||||
for marker in markers:
|
for marker in markers:
|
||||||
size = struct.pack(">H", 2 + ICC_OVERHEAD_LEN + len(marker))
|
size = struct.pack(">H", 2 + ICC_OVERHEAD_LEN + len(marker))
|
||||||
extra += b"\xFF\xE2" + size + b"ICC_PROFILE\0" + o8(i) + o8(len(markers)) + marker
|
extra += (b"\xFF\xE2" + size + b"ICC_PROFILE\0" + o8(i) +
|
||||||
|
o8(len(markers)) + marker)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
# get keyword arguments
|
# get keyword arguments
|
||||||
|
|
|
@ -48,8 +48,8 @@ You can get the quantization tables of a JPEG with::
|
||||||
|
|
||||||
im.quantization
|
im.quantization
|
||||||
|
|
||||||
This will return a dict with a number of arrays. You can pass this dict directly
|
This will return a dict with a number of arrays. You can pass this dict
|
||||||
as the qtables argument when saving a JPEG.
|
directly as the qtables argument when saving a JPEG.
|
||||||
|
|
||||||
The tables format between im.quantization and quantization in presets differ in
|
The tables format between im.quantization and quantization in presets differ in
|
||||||
3 ways:
|
3 ways:
|
||||||
|
|
|
@ -30,6 +30,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))
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Image plugin for XV thumbnail images.
|
# Image plugin for XV thumbnail images.
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,3 @@ import sys
|
||||||
|
|
||||||
if sys.maxsize < 2**32:
|
if sys.maxsize < 2**32:
|
||||||
im = Image.new('L', (999999, 999999), 0)
|
im = Image.new('L', (999999, 999999), 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from helper import *
|
from helper import unittest, PillowTestCase, lena
|
||||||
|
|
||||||
# Not running this test by default. No DOS against Travis CI.
|
# Not running this test by default. No DOS against Travis CI.
|
||||||
|
|
||||||
|
|
|
@ -7,4 +7,5 @@ from io import BytesIO
|
||||||
if bytes is str:
|
if bytes is str:
|
||||||
Image.open(BytesIO(bytes('icns\x00\x00\x00\x10hang\x00\x00\x00\x00')))
|
Image.open(BytesIO(bytes('icns\x00\x00\x00\x10hang\x00\x00\x00\x00')))
|
||||||
else:
|
else:
|
||||||
Image.open(BytesIO(bytes('icns\x00\x00\x00\x10hang\x00\x00\x00\x00', 'latin-1')))
|
Image.open(BytesIO(bytes('icns\x00\x00\x00\x10hang\x00\x00\x00\x00',
|
||||||
|
'latin-1')))
|
||||||
|
|
|
@ -5,7 +5,9 @@ from PIL import Image
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
if bytes is str:
|
if bytes is str:
|
||||||
Image.open(BytesIO(bytes('\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang')))
|
Image.open(BytesIO(bytes(
|
||||||
|
'\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang')))
|
||||||
else:
|
else:
|
||||||
Image.open(BytesIO(bytes('\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang', 'latin-1')))
|
Image.open(BytesIO(bytes(
|
||||||
|
'\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang',
|
||||||
|
'latin-1')))
|
||||||
|
|
|
@ -9,6 +9,6 @@ i = Image.new("RGB", (500, h), "white")
|
||||||
d = ImageDraw.Draw(i)
|
d = ImageDraw.Draw(i)
|
||||||
|
|
||||||
# this line causes a MemoryError
|
# this line causes a MemoryError
|
||||||
d.text((0,0), s, font=f, fill=0)
|
d.text((0, 0), s, font=f, fill=0)
|
||||||
|
|
||||||
i.show()
|
i.show()
|
||||||
|
|
|
@ -100,7 +100,8 @@ class PillowTestCase(unittest.TestCase):
|
||||||
ave_diff = float(diff)/(a.size[0]*a.size[1])
|
ave_diff = float(diff)/(a.size[0]*a.size[1])
|
||||||
self.assertGreaterEqual(
|
self.assertGreaterEqual(
|
||||||
epsilon, ave_diff,
|
epsilon, ave_diff,
|
||||||
(msg or '') + " average pixel value difference %.4f > epsilon %.4f" % (
|
(msg or '') +
|
||||||
|
" average pixel value difference %.4f > epsilon %.4f" % (
|
||||||
ave_diff, epsilon))
|
ave_diff, epsilon))
|
||||||
|
|
||||||
def assert_warning(self, warn_class, func):
|
def assert_warning(self, warn_class, func):
|
||||||
|
@ -138,7 +139,8 @@ class PillowTestCase(unittest.TestCase):
|
||||||
if travis is not None:
|
if travis is not None:
|
||||||
skip = skip and (travis == bool(os.environ.get('TRAVIS', False)))
|
skip = skip and (travis == bool(os.environ.get('TRAVIS', False)))
|
||||||
if interpreter is not None:
|
if interpreter is not None:
|
||||||
skip = skip and (interpreter == 'pypy' and hasattr(sys, 'pypy_version_info'))
|
skip = skip and (interpreter == 'pypy' and
|
||||||
|
hasattr(sys, 'pypy_version_info'))
|
||||||
if skip:
|
if skip:
|
||||||
self.skipTest(msg or "Known Bad Test")
|
self.skipTest(msg or "Known Bad Test")
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from helper import *
|
from helper import unittest, PillowTestCase
|
||||||
|
|
||||||
# This test is not run automatically.
|
# This test is not run automatically.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from helper import *
|
from helper import unittest, PillowTestCase
|
||||||
|
|
||||||
# This test is not run automatically.
|
# This test is not run automatically.
|
||||||
#
|
#
|
||||||
|
|
|
@ -82,7 +82,8 @@ class TestFileMpo(PillowTestCase):
|
||||||
# prior to first image raises an error, both blatant and borderline
|
# prior to first image raises an error, both blatant and borderline
|
||||||
self.assertRaises(EOFError, im.seek, -1)
|
self.assertRaises(EOFError, im.seek, -1)
|
||||||
self.assertRaises(EOFError, im.seek, -523)
|
self.assertRaises(EOFError, im.seek, -523)
|
||||||
# after the final image raises an error, both blatant and borderline
|
# after the final image raises an error,
|
||||||
|
# both blatant and borderline
|
||||||
self.assertRaises(EOFError, im.seek, 2)
|
self.assertRaises(EOFError, im.seek, 2)
|
||||||
self.assertRaises(EOFError, im.seek, 523)
|
self.assertRaises(EOFError, im.seek, 523)
|
||||||
# bad calls shouldn't change the frame
|
# bad calls shouldn't change the frame
|
||||||
|
|
|
@ -29,7 +29,6 @@ class TestFilePalm(PillowTestCase):
|
||||||
converted = self.open_withImagemagick(outfile)
|
converted = self.open_withImagemagick(outfile)
|
||||||
self.assert_image_equal(converted, im)
|
self.assert_image_equal(converted, im)
|
||||||
|
|
||||||
|
|
||||||
def test_monochrome(self):
|
def test_monochrome(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
mode = "1"
|
mode = "1"
|
||||||
|
|
|
@ -151,13 +151,16 @@ class TestFilePng(PillowTestCase):
|
||||||
self.assertEqual(im.info["spam"].lang, "en")
|
self.assertEqual(im.info["spam"].lang, "en")
|
||||||
self.assertEqual(im.info["spam"].tkey, "Spam")
|
self.assertEqual(im.info["spam"].tkey, "Spam")
|
||||||
|
|
||||||
im = load(HEAD + chunk(b'iTXt', b'spam\0\1\0en\0Spam\0' + zlib.compress(b"egg")[:1]) + TAIL)
|
im = load(HEAD + chunk(b'iTXt', b'spam\0\1\0en\0Spam\0' +
|
||||||
|
zlib.compress(b"egg")[:1]) + TAIL)
|
||||||
self.assertEqual(im.info, {})
|
self.assertEqual(im.info, {})
|
||||||
|
|
||||||
im = load(HEAD + chunk(b'iTXt', b'spam\0\1\1en\0Spam\0' + zlib.compress(b"egg")) + TAIL)
|
im = load(HEAD + chunk(b'iTXt', b'spam\0\1\1en\0Spam\0' +
|
||||||
|
zlib.compress(b"egg")) + TAIL)
|
||||||
self.assertEqual(im.info, {})
|
self.assertEqual(im.info, {})
|
||||||
|
|
||||||
im = load(HEAD + chunk(b'iTXt', b'spam\0\1\0en\0Spam\0' + zlib.compress(b"egg")) + TAIL)
|
im = load(HEAD + chunk(b'iTXt', b'spam\0\1\0en\0Spam\0' +
|
||||||
|
zlib.compress(b"egg")) + TAIL)
|
||||||
self.assertEqual(im.info, {"spam": "egg"})
|
self.assertEqual(im.info, {"spam": "egg"})
|
||||||
self.assertEqual(im.info["spam"].lang, "en")
|
self.assertEqual(im.info["spam"].lang, "en")
|
||||||
self.assertEqual(im.info["spam"].tkey, "Spam")
|
self.assertEqual(im.info["spam"].tkey, "Spam")
|
||||||
|
@ -271,7 +274,8 @@ class TestFilePng(PillowTestCase):
|
||||||
im = Image.new("RGB", (32, 32))
|
im = Image.new("RGB", (32, 32))
|
||||||
info = PngImagePlugin.PngInfo()
|
info = PngImagePlugin.PngInfo()
|
||||||
info.add_itxt("spam", "Eggs", "en", "Spam")
|
info.add_itxt("spam", "Eggs", "en", "Spam")
|
||||||
info.add_text("eggs", PngImagePlugin.iTXt("Spam", "en", "Eggs"), zip=True)
|
info.add_text("eggs", PngImagePlugin.iTXt("Spam", "en", "Eggs"),
|
||||||
|
zip=True)
|
||||||
|
|
||||||
im = roundtrip(im, pnginfo=info)
|
im = roundtrip(im, pnginfo=info)
|
||||||
self.assertEqual(im.info, {"spam": "Eggs", "eggs": "Spam"})
|
self.assertEqual(im.info, {"spam": "Eggs", "eggs": "Spam"})
|
||||||
|
|
|
@ -50,7 +50,8 @@ class TestFileTiffMetadata(PillowTestCase):
|
||||||
'StripByteCounts': (1796,),
|
'StripByteCounts': (1796,),
|
||||||
'SamplesPerPixel': (1,),
|
'SamplesPerPixel': (1,),
|
||||||
'StripOffsets': (8,),
|
'StripOffsets': (8,),
|
||||||
'Software': 'ImageMagick 6.5.7-8 2012-08-17 Q16 http://www.imagemagick.org'}
|
'Software': 'ImageMagick 6.5.7-8 2012-08-17 Q16' +
|
||||||
|
' http://www.imagemagick.org'}
|
||||||
|
|
||||||
# self.assertEqual is equivalent,
|
# self.assertEqual is equivalent,
|
||||||
# but less helpful in telling what's wrong.
|
# but less helpful in telling what's wrong.
|
||||||
|
|
|
@ -18,7 +18,8 @@ class TestFileWebpAlpha(PillowTestCase):
|
||||||
self.skipTest('WebP support not installed')
|
self.skipTest('WebP support not installed')
|
||||||
|
|
||||||
if _webp.WebPDecoderBuggyAlpha(self):
|
if _webp.WebPDecoderBuggyAlpha(self):
|
||||||
self.skipTest("Buggy early version of WebP installed, not testing transparency")
|
self.skipTest("Buggy early version of WebP installed, "
|
||||||
|
"not testing transparency")
|
||||||
|
|
||||||
def test_read_rgba(self):
|
def test_read_rgba(self):
|
||||||
# Generated with `cwebp transparent.png -o transparent.webp`
|
# Generated with `cwebp transparent.png -o transparent.webp`
|
||||||
|
|
|
@ -2,54 +2,60 @@ from helper import unittest, PillowTestCase, lena
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
import colorsys, itertools
|
import colorsys
|
||||||
|
import itertools
|
||||||
|
|
||||||
|
|
||||||
class TestFormatHSV(PillowTestCase):
|
class TestFormatHSV(PillowTestCase):
|
||||||
|
|
||||||
def int_to_float(self, i):
|
def int_to_float(self, i):
|
||||||
return float(i)/255.0
|
return float(i)/255.0
|
||||||
|
|
||||||
def str_to_float(self, i):
|
def str_to_float(self, i):
|
||||||
|
|
||||||
return float(ord(i))/255.0
|
return float(ord(i))/255.0
|
||||||
|
|
||||||
def to_int(self, f):
|
def to_int(self, f):
|
||||||
return int(f*255.0)
|
return int(f*255.0)
|
||||||
|
|
||||||
def tuple_to_ints(self, tp):
|
def tuple_to_ints(self, tp):
|
||||||
x,y,z = tp
|
x, y, z = tp
|
||||||
return (int(x*255.0), int(y*255.0), int(z*255.0))
|
return (int(x*255.0), int(y*255.0), int(z*255.0))
|
||||||
|
|
||||||
def test_sanity(self):
|
def test_sanity(self):
|
||||||
im = Image.new('HSV', (100,100))
|
Image.new('HSV', (100, 100))
|
||||||
|
|
||||||
def wedge(self):
|
def wedge(self):
|
||||||
w =Image._wedge()
|
w = Image._wedge()
|
||||||
w90 = w.rotate(90)
|
w90 = w.rotate(90)
|
||||||
|
|
||||||
(px, h) = w.size
|
(px, h) = w.size
|
||||||
|
|
||||||
r = Image.new('L', (px*3,h))
|
r = Image.new('L', (px*3, h))
|
||||||
g = r.copy()
|
g = r.copy()
|
||||||
b = r.copy()
|
b = r.copy()
|
||||||
|
|
||||||
r.paste(w, (0,0))
|
r.paste(w, (0, 0))
|
||||||
r.paste(w90, (px,0))
|
r.paste(w90, (px, 0))
|
||||||
|
|
||||||
g.paste(w90, (0,0))
|
g.paste(w90, (0, 0))
|
||||||
g.paste(w, (2*px,0))
|
g.paste(w, (2*px, 0))
|
||||||
|
|
||||||
b.paste(w, (px,0))
|
b.paste(w, (px, 0))
|
||||||
b.paste(w90, (2*px,0))
|
b.paste(w90, (2*px, 0))
|
||||||
|
|
||||||
img = Image.merge('RGB',(r,g,b))
|
img = Image.merge('RGB', (r, g, b))
|
||||||
|
|
||||||
#print (("%d, %d -> "% (int(1.75*px),int(.25*px))) + \
|
# print (("%d, %d -> "% (int(1.75*px),int(.25*px))) + \
|
||||||
# "(%s, %s, %s)"%img.getpixel((1.75*px, .25*px)))
|
# "(%s, %s, %s)"%img.getpixel((1.75*px, .25*px)))
|
||||||
#print (("%d, %d -> "% (int(.75*px),int(.25*px))) + \
|
# print (("%d, %d -> "% (int(.75*px),int(.25*px))) + \
|
||||||
# "(%s, %s, %s)"%img.getpixel((.75*px, .25*px)))
|
# "(%s, %s, %s)"%img.getpixel((.75*px, .25*px)))
|
||||||
return img
|
return img
|
||||||
|
|
||||||
def to_xxx_colorsys(self, im, func, mode):
|
def to_xxx_colorsys(self, im, func, mode):
|
||||||
# convert the hard way using the library colorsys routines.
|
# convert the hard way using the library colorsys routines.
|
||||||
|
|
||||||
(r,g,b) = im.split()
|
(r, g, b) = im.split()
|
||||||
|
|
||||||
if bytes is str:
|
if bytes is str:
|
||||||
conv_func = self.str_to_float
|
conv_func = self.str_to_float
|
||||||
|
@ -61,16 +67,19 @@ class TestFormatHSV(PillowTestCase):
|
||||||
else:
|
else:
|
||||||
iter_helper = itertools.zip_longest
|
iter_helper = itertools.zip_longest
|
||||||
|
|
||||||
|
converted = [self.tuple_to_ints(func(conv_func(_r), conv_func(_g),
|
||||||
converted = [self.tuple_to_ints(func(conv_func(_r), conv_func(_g), conv_func(_b)))
|
conv_func(_b)))
|
||||||
for (_r, _g, _b) in iter_helper(r.tobytes(), g.tobytes(), b.tobytes())]
|
for (_r, _g, _b) in iter_helper(r.tobytes(), g.tobytes(),
|
||||||
|
b.tobytes())]
|
||||||
|
|
||||||
if str is bytes:
|
if str is bytes:
|
||||||
new_bytes = b''.join(chr(h)+chr(s)+chr(v) for (h,s,v) in converted)
|
new_bytes = b''.join(chr(h)+chr(s)+chr(v) for (
|
||||||
|
h, s, v) in converted)
|
||||||
else:
|
else:
|
||||||
new_bytes = b''.join(bytes(chr(h)+chr(s)+chr(v), 'latin-1') for (h,s,v) in converted)
|
new_bytes = b''.join(bytes(chr(h)+chr(s)+chr(v), 'latin-1') for (
|
||||||
|
h, s, v) in converted)
|
||||||
|
|
||||||
hsv = Image.frombytes(mode,r.size, new_bytes)
|
hsv = Image.frombytes(mode, r.size, new_bytes)
|
||||||
|
|
||||||
return hsv
|
return hsv
|
||||||
|
|
||||||
|
@ -81,18 +90,18 @@ class TestFormatHSV(PillowTestCase):
|
||||||
return self.to_xxx_colorsys(im, colorsys.hsv_to_rgb, 'RGB')
|
return self.to_xxx_colorsys(im, colorsys.hsv_to_rgb, 'RGB')
|
||||||
|
|
||||||
def test_wedge(self):
|
def test_wedge(self):
|
||||||
src = self.wedge().resize((3*32,32),Image.BILINEAR)
|
src = self.wedge().resize((3*32, 32), Image.BILINEAR)
|
||||||
im = src.convert('HSV')
|
im = src.convert('HSV')
|
||||||
comparable = self.to_hsv_colorsys(src)
|
comparable = self.to_hsv_colorsys(src)
|
||||||
|
|
||||||
#print (im.getpixel((448, 64)))
|
# print (im.getpixel((448, 64)))
|
||||||
#print (comparable.getpixel((448, 64)))
|
# print (comparable.getpixel((448, 64)))
|
||||||
|
|
||||||
#print(im.split()[0].histogram())
|
# print(im.split()[0].histogram())
|
||||||
#print(comparable.split()[0].histogram())
|
# print(comparable.split()[0].histogram())
|
||||||
|
|
||||||
#im.split()[0].show()
|
# im.split()[0].show()
|
||||||
#comparable.split()[0].show()
|
# comparable.split()[0].show()
|
||||||
|
|
||||||
self.assert_image_similar(im.split()[0], comparable.split()[0],
|
self.assert_image_similar(im.split()[0], comparable.split()[0],
|
||||||
1, "Hue conversion is wrong")
|
1, "Hue conversion is wrong")
|
||||||
|
@ -101,15 +110,15 @@ class TestFormatHSV(PillowTestCase):
|
||||||
self.assert_image_similar(im.split()[2], comparable.split()[2],
|
self.assert_image_similar(im.split()[2], comparable.split()[2],
|
||||||
1, "Value conversion is wrong")
|
1, "Value conversion is wrong")
|
||||||
|
|
||||||
#print (im.getpixel((192, 64)))
|
# print (im.getpixel((192, 64)))
|
||||||
|
|
||||||
comparable = src
|
comparable = src
|
||||||
im = im.convert('RGB')
|
im = im.convert('RGB')
|
||||||
|
|
||||||
#im.split()[0].show()
|
# im.split()[0].show()
|
||||||
#comparable.split()[0].show()
|
# comparable.split()[0].show()
|
||||||
#print (im.getpixel((192, 64)))
|
# print (im.getpixel((192, 64)))
|
||||||
#print (comparable.getpixel((192, 64)))
|
# print (comparable.getpixel((192, 64)))
|
||||||
|
|
||||||
self.assert_image_similar(im.split()[0], comparable.split()[0],
|
self.assert_image_similar(im.split()[0], comparable.split()[0],
|
||||||
3, "R conversion is wrong")
|
3, "R conversion is wrong")
|
||||||
|
@ -118,7 +127,6 @@ class TestFormatHSV(PillowTestCase):
|
||||||
self.assert_image_similar(im.split()[2], comparable.split()[2],
|
self.assert_image_similar(im.split()[2], comparable.split()[2],
|
||||||
3, "B conversion is wrong")
|
3, "B conversion is wrong")
|
||||||
|
|
||||||
|
|
||||||
def test_convert(self):
|
def test_convert(self):
|
||||||
im = lena('RGB').convert('HSV')
|
im = lena('RGB').convert('HSV')
|
||||||
comparable = self.to_hsv_colorsys(lena('RGB'))
|
comparable = self.to_hsv_colorsys(lena('RGB'))
|
||||||
|
@ -136,7 +144,6 @@ class TestFormatHSV(PillowTestCase):
|
||||||
self.assert_image_similar(im.split()[2], comparable.split()[2],
|
self.assert_image_similar(im.split()[2], comparable.split()[2],
|
||||||
1, "Value conversion is wrong")
|
1, "Value conversion is wrong")
|
||||||
|
|
||||||
|
|
||||||
def test_hsv_to_rgb(self):
|
def test_hsv_to_rgb(self):
|
||||||
comparable = self.to_hsv_colorsys(lena('RGB'))
|
comparable = self.to_hsv_colorsys(lena('RGB'))
|
||||||
converted = comparable.convert('RGB')
|
converted = comparable.convert('RGB')
|
||||||
|
@ -148,7 +155,6 @@ class TestFormatHSV(PillowTestCase):
|
||||||
# print ([ord(x) for x in target.split()[1].tobytes()[:80]])
|
# print ([ord(x) for x in target.split()[1].tobytes()[:80]])
|
||||||
# print ([ord(x) for x in converted.split()[1].tobytes()[:80]])
|
# print ([ord(x) for x in converted.split()[1].tobytes()[:80]])
|
||||||
|
|
||||||
|
|
||||||
self.assert_image_similar(converted.split()[0], comparable.split()[0],
|
self.assert_image_similar(converted.split()[0], comparable.split()[0],
|
||||||
3, "R conversion is wrong")
|
3, "R conversion is wrong")
|
||||||
self.assert_image_similar(converted.split()[1], comparable.split()[1],
|
self.assert_image_similar(converted.split()[1], comparable.split()[1],
|
||||||
|
@ -157,12 +163,6 @@ class TestFormatHSV(PillowTestCase):
|
||||||
3, "B conversion is wrong")
|
3, "B conversion is wrong")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from helper import unittest, PillowTestCase, lena
|
from helper import unittest, PillowTestCase, lena
|
||||||
|
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
|
|
||||||
class TestImageCopy(PillowTestCase):
|
class TestImageCopy(PillowTestCase):
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from helper import unittest, PillowTestCase, lena
|
from helper import unittest, PillowTestCase, lena
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
class TestImagePoint(PillowTestCase):
|
class TestImagePoint(PillowTestCase):
|
||||||
|
|
||||||
|
@ -26,7 +24,7 @@ class TestImagePoint(PillowTestCase):
|
||||||
"""
|
"""
|
||||||
# This takes _forever_ on PyPy. Open Bug,
|
# This takes _forever_ on PyPy. Open Bug,
|
||||||
# see https://github.com/python-pillow/Pillow/issues/484
|
# see https://github.com/python-pillow/Pillow/issues/484
|
||||||
#self.skipKnownBadTest(msg="Too Slow on pypy", interpreter='pypy')
|
# self.skipKnownBadTest(msg="Too Slow on pypy", interpreter='pypy')
|
||||||
|
|
||||||
im = lena("I")
|
im = lena("I")
|
||||||
im.point(list(range(256))*256, 'L')
|
im.point(list(range(256))*256, 'L')
|
||||||
|
|
|
@ -41,9 +41,8 @@ class TestImagePutData(PillowTestCase):
|
||||||
else:
|
else:
|
||||||
self.assertEqual(put(sys.maxsize), (255, 255, 255, 127))
|
self.assertEqual(put(sys.maxsize), (255, 255, 255, 127))
|
||||||
|
|
||||||
|
|
||||||
def test_pypy_performance(self):
|
def test_pypy_performance(self):
|
||||||
im = Image.new('L', (256,256))
|
im = Image.new('L', (256, 256))
|
||||||
im.putdata(list(range(256))*256)
|
im.putdata(list(range(256))*256)
|
||||||
|
|
||||||
def test_mode_i(self):
|
def test_mode_i(self):
|
||||||
|
@ -52,7 +51,7 @@ class TestImagePutData(PillowTestCase):
|
||||||
im = Image.new('I', src.size, 0)
|
im = Image.new('I', src.size, 0)
|
||||||
im.putdata(data, 2, 256)
|
im.putdata(data, 2, 256)
|
||||||
|
|
||||||
target = [2* elt + 256 for elt in data]
|
target = [2 * elt + 256 for elt in data]
|
||||||
self.assertEqual(list(im.getdata()), target)
|
self.assertEqual(list(im.getdata()), target)
|
||||||
|
|
||||||
def test_mode_F(self):
|
def test_mode_F(self):
|
||||||
|
@ -61,11 +60,10 @@ class TestImagePutData(PillowTestCase):
|
||||||
im = Image.new('F', src.size, 0)
|
im = Image.new('F', src.size, 0)
|
||||||
im.putdata(data, 2.0, 256.0)
|
im.putdata(data, 2.0, 256.0)
|
||||||
|
|
||||||
target = [2.0* float(elt) + 256.0 for elt in data]
|
target = [2.0 * float(elt) + 256.0 for elt in data]
|
||||||
self.assertEqual(list(im.getdata()), target)
|
self.assertEqual(list(im.getdata()), target)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,6 @@ class TestImageCms(PillowTestCase):
|
||||||
profile = ImageCmsProfile(BytesIO(img_srgb.info['icc_profile']))
|
profile = ImageCmsProfile(BytesIO(img_srgb.info['icc_profile']))
|
||||||
self.assertTrue('sRGB' in ImageCms.getProfileDescription(profile))
|
self.assertTrue('sRGB' in ImageCms.getProfileDescription(profile))
|
||||||
|
|
||||||
|
|
||||||
def test_lab_roundtrip(self):
|
def test_lab_roundtrip(self):
|
||||||
# check to see if we're at least internally consistent.
|
# check to see if we're at least internally consistent.
|
||||||
pLab = ImageCms.createProfile("LAB")
|
pLab = ImageCms.createProfile("LAB")
|
||||||
|
@ -221,7 +220,6 @@ class TestImageCms(PillowTestCase):
|
||||||
|
|
||||||
self.assert_image_similar(lena(), out, 2)
|
self.assert_image_similar(lena(), out, 2)
|
||||||
|
|
||||||
|
|
||||||
def test_profile_tobytes(self):
|
def test_profile_tobytes(self):
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
i = Image.open("Tests/images/rgb.jpg")
|
i = Image.open("Tests/images/rgb.jpg")
|
||||||
|
@ -231,14 +229,13 @@ class TestImageCms(PillowTestCase):
|
||||||
|
|
||||||
# not the same bytes as the original icc_profile,
|
# not the same bytes as the original icc_profile,
|
||||||
# but it does roundtrip
|
# but it does roundtrip
|
||||||
self.assertEqual(p.tobytes(),p2.tobytes())
|
self.assertEqual(p.tobytes(), p2.tobytes())
|
||||||
self.assertEqual(ImageCms.getProfileName(p),
|
self.assertEqual(ImageCms.getProfileName(p),
|
||||||
ImageCms.getProfileName(p2))
|
ImageCms.getProfileName(p2))
|
||||||
self.assertEqual(ImageCms.getProfileDescription(p),
|
self.assertEqual(ImageCms.getProfileDescription(p),
|
||||||
ImageCms.getProfileDescription(p2))
|
ImageCms.getProfileDescription(p2))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
|
@ -350,12 +350,15 @@ class TestImageDraw(PillowTestCase):
|
||||||
expected.load()
|
expected.load()
|
||||||
img, draw = self.create_base_image_draw((110, 200))
|
img, draw = self.create_base_image_draw((110, 200))
|
||||||
draw.line((55, 5, 55, 195), BLACK, 101)
|
draw.line((55, 5, 55, 195), BLACK, 101)
|
||||||
self.assert_image_equal(img, expected, 'line straigth vertical 101px wide failed')
|
self.assert_image_equal(img, expected,
|
||||||
expected = Image.open(os.path.join(IMAGES_PATH, 'line_vertical_slope1px_w2px.png'))
|
'line straigth vertical 101px wide failed')
|
||||||
|
expected = Image.open(os.path.join(IMAGES_PATH,
|
||||||
|
'line_vertical_slope1px_w2px.png'))
|
||||||
expected.load()
|
expected.load()
|
||||||
img, draw = self.create_base_image_draw((20, 20))
|
img, draw = self.create_base_image_draw((20, 20))
|
||||||
draw.line((5, 5, 6, 14), BLACK, 2)
|
draw.line((5, 5, 6, 14), BLACK, 2)
|
||||||
self.assert_image_equal(img, expected, 'line vertical 1px slope 2px wide failed')
|
self.assert_image_equal(img, expected,
|
||||||
|
'line vertical 1px slope 2px wide failed')
|
||||||
|
|
||||||
|
|
||||||
def test_line_oblique_45(self):
|
def test_line_oblique_45(self):
|
||||||
|
@ -363,22 +366,26 @@ class TestImageDraw(PillowTestCase):
|
||||||
expected.load()
|
expected.load()
|
||||||
img, draw = self.create_base_image_draw((20, 20))
|
img, draw = self.create_base_image_draw((20, 20))
|
||||||
draw.line((5, 5, 14, 14), BLACK, 3)
|
draw.line((5, 5, 14, 14), BLACK, 3)
|
||||||
self.assert_image_equal(img, expected, 'line oblique 45 normal 3px wide A failed')
|
self.assert_image_equal(img, expected,
|
||||||
|
'line oblique 45 normal 3px wide A failed')
|
||||||
img, draw = self.create_base_image_draw((20, 20))
|
img, draw = self.create_base_image_draw((20, 20))
|
||||||
draw.line((14, 14, 5, 5), BLACK, 3)
|
draw.line((14, 14, 5, 5), BLACK, 3)
|
||||||
self.assert_image_equal(img, expected, 'line oblique 45 inverted 3px wide A failed')
|
self.assert_image_equal(img, expected,
|
||||||
expected = Image.open(os.path.join(IMAGES_PATH, 'line_oblique_45_w3px_b.png'))
|
'line oblique 45 inverted 3px wide A failed')
|
||||||
|
expected = Image.open(os.path.join(IMAGES_PATH,
|
||||||
|
'line_oblique_45_w3px_b.png'))
|
||||||
expected.load()
|
expected.load()
|
||||||
img, draw = self.create_base_image_draw((20, 20))
|
img, draw = self.create_base_image_draw((20, 20))
|
||||||
draw.line((14, 5, 5, 14), BLACK, 3)
|
draw.line((14, 5, 5, 14), BLACK, 3)
|
||||||
self.assert_image_equal(img, expected, 'line oblique 45 normal 3px wide B failed')
|
self.assert_image_equal(img, expected,
|
||||||
|
'line oblique 45 normal 3px wide B failed')
|
||||||
img, draw = self.create_base_image_draw((20, 20))
|
img, draw = self.create_base_image_draw((20, 20))
|
||||||
draw.line((5, 14, 14, 5), BLACK, 3)
|
draw.line((5, 14, 14, 5), BLACK, 3)
|
||||||
self.assert_image_equal(img, expected, 'line oblique 45 inverted 3px wide B failed')
|
self.assert_image_equal(img, expected,
|
||||||
|
'line oblique 45 inverted 3px wide B failed')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
# End of file
|
# End of file
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Test the ImageMorphology functionality
|
# Test the ImageMorphology functionality
|
||||||
from helper import *
|
from helper import unittest, PillowTestCase
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from PIL import ImageMorph
|
from PIL import ImageMorph
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from helper import unittest, PillowTestCase, lena
|
from helper import unittest, PillowTestCase
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from PIL import ImageWin
|
from PIL import ImageWin
|
||||||
|
|
|
@ -5,7 +5,7 @@ from PIL import Image
|
||||||
|
|
||||||
class TestModeI16(PillowTestCase):
|
class TestModeI16(PillowTestCase):
|
||||||
|
|
||||||
original = lena().resize((32,32)).convert('I')
|
original = lena().resize((32, 32)).convert('I')
|
||||||
|
|
||||||
def verify(self, im1):
|
def verify(self, im1):
|
||||||
im2 = self.original.copy()
|
im2 = self.original.copy()
|
||||||
|
|
|
@ -17,6 +17,7 @@ test_filenames = (
|
||||||
"temp_'\"&&",
|
"temp_'\"&&",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(sys.platform.startswith('win32'), "requires Unix or MacOS")
|
@unittest.skipIf(sys.platform.startswith('win32'), "requires Unix or MacOS")
|
||||||
class TestShellInjection(PillowTestCase):
|
class TestShellInjection(PillowTestCase):
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
import sys, time
|
|
||||||
import io
|
import io
|
||||||
import threading, queue
|
import queue
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
try:
|
try:
|
||||||
format = sys.argv[1]
|
format = sys.argv[1]
|
||||||
|
@ -16,6 +18,7 @@ queue = queue.Queue()
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
|
|
||||||
class Worker(threading.Thread):
|
class Worker(threading.Thread):
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
def version(module, version):
|
def version(module, version):
|
||||||
v = getattr(module.core, version + "_version", None)
|
v = getattr(module.core, version + "_version", None)
|
||||||
if v:
|
if v:
|
||||||
|
|
|
@ -57,6 +57,7 @@ if MAX_PROCS != 1:
|
||||||
pool = Pool(2)
|
pool = Pool(2)
|
||||||
CCompiler.compile = _mp_compile
|
CCompiler.compile = _mp_compile
|
||||||
except Exception as msg:
|
except Exception as msg:
|
||||||
print("Exception installing mp_compile, proceeding without: %s" %msg)
|
print("Exception installing mp_compile, proceeding without: %s" % msg)
|
||||||
else:
|
else:
|
||||||
print("Single threaded build, not installing mp_compile: %s processes" %MAX_PROCS)
|
print("Single threaded build, not installing mp_compile: %s processes" %
|
||||||
|
MAX_PROCS)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user