mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
commit
0d0a4e4ebe
|
@ -670,6 +670,5 @@ class TestFileLibTiff(LibTiffTestCase):
|
|||
self.assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -425,21 +425,24 @@ class TestFileTiff(PillowTestCase):
|
|||
infile = "Tests/images/tiff_strip_raw.tif"
|
||||
im = Image.open(infile)
|
||||
|
||||
self.assert_image_equal_tofile(im, "Tests/images/tiff_adobe_deflate.png")
|
||||
self.assert_image_equal_tofile(im,
|
||||
"Tests/images/tiff_adobe_deflate.png")
|
||||
|
||||
def test_strip_planar_raw(self):
|
||||
# gdal_translate -of GTiff -co INTERLEAVE=BAND tiff_strip_raw.tif tiff_strip_planar_raw.tiff
|
||||
infile = "Tests/images/tiff_strip_planar_raw.tif"
|
||||
im = Image.open(infile)
|
||||
|
||||
self.assert_image_equal_tofile(im, "Tests/images/tiff_adobe_deflate.png")
|
||||
self.assert_image_equal_tofile(im,
|
||||
"Tests/images/tiff_adobe_deflate.png")
|
||||
|
||||
def test_strip_planar_raw_with_overviews(self):
|
||||
# gdaladdo tiff_strip_planar_raw2.tif 2 4 8 16
|
||||
infile = "Tests/images/tiff_strip_planar_raw_with_overviews.tif"
|
||||
im = Image.open(infile)
|
||||
|
||||
self.assert_image_equal_tofile(im, "Tests/images/tiff_adobe_deflate.png")
|
||||
self.assert_image_equal_tofile(im,
|
||||
"Tests/images/tiff_adobe_deflate.png")
|
||||
|
||||
def test_tiled_planar_raw(self):
|
||||
# gdal_translate -of GTiff -co TILED=YES -co BLOCKXSIZE=32 -co BLOCKYSIZE=32 -co INTERLEAVE=BAND \
|
||||
|
@ -447,7 +450,8 @@ class TestFileTiff(PillowTestCase):
|
|||
infile = "Tests/images/tiff_tiled_planar_raw.tif"
|
||||
im = Image.open(infile)
|
||||
|
||||
self.assert_image_equal_tofile(im, "Tests/images/tiff_adobe_deflate.png")
|
||||
self.assert_image_equal_tofile(im,
|
||||
"Tests/images/tiff_adobe_deflate.png")
|
||||
|
||||
def test_tiff_save_all(self):
|
||||
import io
|
||||
|
|
|
@ -22,7 +22,6 @@ class TestUnsupportedWebp(PillowTestCase):
|
|||
WebPImagePlugin.SUPPORTED = True
|
||||
|
||||
|
||||
|
||||
@unittest.skipIf(not HAVE_WEBP, "WebP support not installed")
|
||||
class TestFileWebp(PillowTestCase):
|
||||
|
||||
|
|
|
@ -20,7 +20,14 @@ has the following structure:
|
|||
{format_directory}
|
||||
{data}
|
||||
Where:
|
||||
{header} = { u32:magic, u32:version, u32:width, u32:height, u32:mipmap_count, u32:format_count }
|
||||
{header} = {
|
||||
u32:magic,
|
||||
u32:version,
|
||||
u32:width,
|
||||
u32:height,
|
||||
u32:mipmap_count,
|
||||
u32:format_count
|
||||
}
|
||||
|
||||
* The "magic" number is "FTEX".
|
||||
* "width" and "height" are the dimensions of the texture.
|
||||
|
|
|
@ -284,7 +284,7 @@ class IcnsImageFile(ImageFile.ImageFile):
|
|||
if info_size not in self.info['sizes'] and len(info_size) == 3 and \
|
||||
info_size[2] == 1:
|
||||
simple_sizes = [(size[0] * size[2], size[1] * size[2])
|
||||
for size in self.info['sizes']]
|
||||
for size in self.info['sizes']]
|
||||
if value in simple_sizes:
|
||||
info_size = self.info['sizes'][simple_sizes.index(value)]
|
||||
if info_size not in self.info['sizes']:
|
||||
|
@ -333,6 +333,7 @@ def _save(im, fp, filename):
|
|||
provided_images = {im.width: im
|
||||
for im in im.encoderinfo.get("append_images", [])}
|
||||
last_w = None
|
||||
second_path = None
|
||||
for w in [16, 32, 128, 256, 512]:
|
||||
prefix = 'icon_{}x{}'.format(w, w)
|
||||
|
||||
|
|
|
@ -1047,7 +1047,8 @@ class Image(object):
|
|||
2 = fast octree
|
||||
3 = libimagequant
|
||||
:param kmeans: Integer
|
||||
:param palette: Quantize to the palette of given :py:class:`PIL.Image.Image`.
|
||||
:param palette: Quantize to the palette of given
|
||||
:py:class:`PIL.Image.Image`.
|
||||
:returns: A new image
|
||||
|
||||
"""
|
||||
|
@ -1773,11 +1774,10 @@ class Image(object):
|
|||
if self.mode in ("1", "P"):
|
||||
resample = NEAREST
|
||||
|
||||
if self.mode == 'LA':
|
||||
return self.convert('La').resize(size, resample, box).convert('LA')
|
||||
|
||||
if self.mode == 'RGBA':
|
||||
return self.convert('RGBa').resize(size, resample, box).convert('RGBA')
|
||||
if self.mode in ['LA', 'RGBA']:
|
||||
im = self.convert(self.mode[:-1]+'a')
|
||||
im = im.resize(size, resample, box)
|
||||
return im.convert(self.mode)
|
||||
|
||||
self.load()
|
||||
|
||||
|
@ -1849,7 +1849,8 @@ class Image(object):
|
|||
else:
|
||||
post_trans = translate
|
||||
if center is None:
|
||||
rotn_center = (w / 2.0, h / 2.0) # FIXME These should be rounded to ints?
|
||||
# FIXME These should be rounded to ints?
|
||||
rotn_center = (w / 2.0, h / 2.0)
|
||||
else:
|
||||
rotn_center = center
|
||||
|
||||
|
@ -1864,7 +1865,8 @@ class Image(object):
|
|||
return a*x + b*y + c, d*x + e*y + f
|
||||
|
||||
matrix[2], matrix[5] = transform(-rotn_center[0] - post_trans[0],
|
||||
-rotn_center[1] - post_trans[1], matrix)
|
||||
-rotn_center[1] - post_trans[1],
|
||||
matrix)
|
||||
matrix[2] += rotn_center[0]
|
||||
matrix[5] += rotn_center[1]
|
||||
|
||||
|
@ -1887,7 +1889,8 @@ class Image(object):
|
|||
matrix)
|
||||
w, h = nw, nh
|
||||
|
||||
return self.transform((w, h), AFFINE, matrix, resample, fillcolor=fillcolor)
|
||||
return self.transform((w, h), AFFINE, matrix, resample,
|
||||
fillcolor=fillcolor)
|
||||
|
||||
def save(self, fp, format=None, **params):
|
||||
"""
|
||||
|
@ -2154,8 +2157,8 @@ class Image(object):
|
|||
:param fill: If **method** is an
|
||||
:py:class:`~PIL.Image.ImageTransformHandler` object, this is one of
|
||||
the arguments passed to it. Otherwise, it is unused.
|
||||
:param fillcolor: Optional fill color for the area outside the transform
|
||||
in the output image.
|
||||
:param fillcolor: Optional fill color for the area outside the
|
||||
transform in the output image.
|
||||
:returns: An :py:class:`~PIL.Image.Image` object.
|
||||
"""
|
||||
|
||||
|
@ -2620,6 +2623,7 @@ def open(fp, mode="r"):
|
|||
preinit()
|
||||
|
||||
accept_warnings = []
|
||||
|
||||
def _open_core(fp, filename, prefix):
|
||||
for i in ID:
|
||||
try:
|
||||
|
|
|
@ -647,7 +647,7 @@ def createProfile(colorSpace, colorTemp=-1):
|
|||
if colorSpace == "LAB":
|
||||
try:
|
||||
colorTemp = float(colorTemp)
|
||||
except:
|
||||
except (TypeError, ValueError):
|
||||
raise PyCMSError(
|
||||
"Color temperature must be numeric, \"%s\" not valid"
|
||||
% colorTemp)
|
||||
|
|
|
@ -406,7 +406,9 @@ def floodfill(image, xy, value, border=None, thresh=0):
|
|||
except (ValueError, IndexError):
|
||||
return # seed point outside image
|
||||
edge = {(x, y)}
|
||||
full_edge = set() # use a set to keep record of current and previous edge pixels to reduce memory consumption
|
||||
# use a set to keep record of current and previous edge pixels
|
||||
# to reduce memory consumption
|
||||
full_edge = set()
|
||||
while edge:
|
||||
new_edge = set()
|
||||
for (x, y) in edge: # 4 adjacent method
|
||||
|
|
|
@ -467,7 +467,7 @@ class Color3DLUT(MultibandFilter):
|
|||
def __repr__(self):
|
||||
r = [
|
||||
"{} from {}".format(self.__class__.__name__,
|
||||
self.table.__class__.__name__),
|
||||
self.table.__class__.__name__),
|
||||
"size={:d}x{:d}x{:d}".format(*self.size),
|
||||
"channels={:d}".format(self.channels),
|
||||
]
|
||||
|
|
|
@ -203,7 +203,7 @@ class FreeTypeFont(object):
|
|||
size=self.size if size is None else size,
|
||||
index=self.index if index is None else index,
|
||||
encoding=self.encoding if encoding is None else encoding,
|
||||
layout_engine=self.layout_engine if layout_engine is None else layout_engine
|
||||
layout_engine=layout_engine or self.layout_engine
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ def grabclipboard():
|
|||
commands = [
|
||||
"set theFile to (open for access POSIX file \""+filepath+"\" with write permission)",
|
||||
"try",
|
||||
"write (the clipboard as JPEG picture) to theFile",
|
||||
" write (the clipboard as JPEG picture) to theFile",
|
||||
"end try",
|
||||
"close access theFile"
|
||||
]
|
||||
|
|
|
@ -441,7 +441,10 @@ def fit(image, size, method=Image.NEAREST, bleed=0.0, centering=(0.5, 0.5)):
|
|||
crop_left = bleed_pixels[0] + (live_size[0]-crop_width) * centering[0]
|
||||
crop_top = bleed_pixels[1] + (live_size[1]-crop_height) * centering[1]
|
||||
|
||||
crop = (crop_left, crop_top, crop_left + crop_width, crop_top + crop_height)
|
||||
crop = (
|
||||
crop_left, crop_top,
|
||||
crop_left + crop_width, crop_top + crop_height
|
||||
)
|
||||
|
||||
# resize the image and return it
|
||||
return image.resize(size, method, box=crop)
|
||||
|
|
|
@ -185,8 +185,8 @@ if qt_is_installed:
|
|||
An PIL image wrapper for Qt. This is a subclass of PyQt's QImage
|
||||
class.
|
||||
|
||||
:param im: A PIL Image object, or a file name (given either as Python
|
||||
string or a PyQt string object).
|
||||
:param im: A PIL Image object, or a file name (given either as
|
||||
Python string or a PyQt string object).
|
||||
"""
|
||||
im_data = _toqclass_helper(im)
|
||||
# must keep a reference, or Qt will crash!
|
||||
|
|
|
@ -32,7 +32,8 @@ def _accept(prefix):
|
|||
|
||||
if is_riff_file_format and is_webp_file and is_valid_vp8_mode:
|
||||
if not SUPPORTED:
|
||||
return "image file could not be identified because WEBP support not installed"
|
||||
return "image file could not be identified " \
|
||||
"because WEBP support not installed"
|
||||
return True
|
||||
|
||||
|
||||
|
@ -253,7 +254,8 @@ def _save_all(im, fp, filename):
|
|||
rawmode = ims.mode
|
||||
if ims.mode not in _VALID_WEBP_MODES:
|
||||
alpha = 'A' in ims.mode or 'a' in ims.mode \
|
||||
or (ims.mode == 'P' and 'A' in ims.im.getpalettemode())
|
||||
or (ims.mode == 'P' and
|
||||
'A' in ims.im.getpalettemode())
|
||||
rawmode = 'RGBA' if alpha else 'RGB'
|
||||
frame = ims.convert(rawmode)
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ def vc_setup(compiler, bit):
|
|||
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %s""" % arch
|
||||
return script
|
||||
|
||||
|
||||
def build_one(py_ver, compiler, bit):
|
||||
# UNDONE virtual envs if we're not running on appveyor
|
||||
args = {}
|
||||
|
|
|
@ -3,12 +3,12 @@ import os
|
|||
SF_MIRROR = 'http://iweb.dl.sourceforge.net'
|
||||
PILLOW_DEPENDS_DIR = 'C:\\pillow-depends\\'
|
||||
|
||||
pythons = {'27': {'compiler':7, 'vc':2008},
|
||||
'pypy2': {'compiler':7, 'vc':2008},
|
||||
'34': {'compiler':7.1, 'vc':2010},
|
||||
'35': {'compiler':7.1, 'vc':2015},
|
||||
'36': {'compiler':7.1, 'vc':2015},
|
||||
'37': {'compiler':7.1, 'vc':2015}}
|
||||
pythons = {'27': {'compiler': 7, 'vc': 2008},
|
||||
'pypy2': {'compiler': 7, 'vc': 2008},
|
||||
'34': {'compiler': 7.1, 'vc': 2010},
|
||||
'35': {'compiler': 7.1, 'vc': 2015},
|
||||
'36': {'compiler': 7.1, 'vc': 2015},
|
||||
'37': {'compiler': 7.1, 'vc': 2015}}
|
||||
|
||||
VIRT_BASE = "c:/vp/"
|
||||
X64_EXT = os.environ.get('X64_EXT', "x64")
|
||||
|
@ -165,11 +165,13 @@ def compiler_from_env():
|
|||
bit = bit_from_env()
|
||||
return compilers[py_info['compiler']][py_info['vc']][bit]
|
||||
|
||||
|
||||
def bit_from_env():
|
||||
py = os.environ['PYTHON']
|
||||
|
||||
return 64 if '64' in py else 32
|
||||
|
||||
|
||||
def all_compilers():
|
||||
all = []
|
||||
for vc_compilers in compilers.values():
|
||||
|
|
Loading…
Reference in New Issue
Block a user