mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
flake8: E501 line too long
This commit is contained in:
parent
7d625940ae
commit
ceebfc6fe8
|
@ -429,7 +429,8 @@ class TestFileTiff(PillowTestCase):
|
|||
"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
|
||||
# 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)
|
||||
|
||||
|
@ -445,7 +446,8 @@ class TestFileTiff(PillowTestCase):
|
|||
"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 \
|
||||
# gdal_translate -of GTiff -co TILED=YES -co BLOCKXSIZE=32 \
|
||||
# -co BLOCKYSIZE=32 -co INTERLEAVE=BAND \
|
||||
# tiff_tiled_raw.tif tiff_tiled_planar_raw.tiff
|
||||
infile = "Tests/images/tiff_tiled_planar_raw.tif"
|
||||
im = Image.open(infile)
|
||||
|
|
|
@ -294,7 +294,14 @@ class TestImageCms(PillowTestCase):
|
|||
p.blue_primary,
|
||||
((0.14306641366715667, 0.06060790921083026, 0.7140960805782015),
|
||||
(0.15588475410450106, 0.06603820408959558, 0.06060790921083026)))
|
||||
assert_truncated_tuple_equal(p.chromatic_adaptation, (((1.04791259765625, 0.0229339599609375, -0.050201416015625), (0.02960205078125, 0.9904632568359375, -0.0170745849609375), (-0.009246826171875, 0.0150604248046875, 0.7517852783203125)), ((1.0267159024652783, 0.022470062342089134, 0.0229339599609375), (0.02951378324103937, 0.9875098886387147, 0.9904632568359375), (-0.012205438066465256, 0.01987915407854985, 0.0150604248046875))))
|
||||
assert_truncated_tuple_equal(
|
||||
p.chromatic_adaptation,
|
||||
(((1.04791259765625, 0.0229339599609375, -0.050201416015625),
|
||||
(0.02960205078125, 0.9904632568359375, -0.0170745849609375),
|
||||
(-0.009246826171875, 0.0150604248046875, 0.7517852783203125)),
|
||||
((1.0267159024652783, 0.022470062342089134, 0.0229339599609375),
|
||||
(0.02951378324103937, 0.9875098886387147, 0.9904632568359375),
|
||||
(-0.012205438066465256, 0.01987915407854985, 0.0150604248046875))))
|
||||
self.assertIsNone(p.chromaticity)
|
||||
self.assertEqual(p.clut, {
|
||||
0: (False, False, True),
|
||||
|
@ -421,7 +428,11 @@ class TestImageCms(PillowTestCase):
|
|||
)
|
||||
channel_data = Image.new(channel_type, channel_pattern.size)
|
||||
for delta in nine_grid_deltas:
|
||||
channel_data.paste(channel_pattern, tuple(paste_offset[c] + delta[c]*channel_pattern.size[c] for c in range(2)))
|
||||
channel_data.paste(
|
||||
channel_pattern,
|
||||
tuple(paste_offset[c] + delta[c] * channel_pattern.size[c]
|
||||
for c in range(2)),
|
||||
)
|
||||
chans.append(channel_data)
|
||||
return Image.merge(mode, chans)
|
||||
|
||||
|
|
|
@ -270,7 +270,8 @@ man_pages = [
|
|||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'PillowPILFork', u'Pillow (PIL Fork) Documentation',
|
||||
author, 'PillowPILFork', 'Pillow is the friendly PIL fork by Alex Clark and Contributors.',
|
||||
author, 'PillowPILFork',
|
||||
'Pillow is the friendly PIL fork by Alex Clark and Contributors.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
|
|
@ -50,16 +50,17 @@ def _accept(prefix):
|
|||
return prefix[:2] == b"BM"
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# =============================================================================
|
||||
# Image plugin for the Windows BMP format.
|
||||
# ==============================================================================
|
||||
# =============================================================================
|
||||
class BmpImageFile(ImageFile.ImageFile):
|
||||
""" Image plugin for the Windows Bitmap format (BMP) """
|
||||
|
||||
# -------------------------------------------------------------- Description
|
||||
# ------------------------------------------------------------- Description
|
||||
format_description = "Windows Bitmap"
|
||||
format = "BMP"
|
||||
# --------------------------------------------------- BMP Compression values
|
||||
|
||||
# -------------------------------------------------- BMP Compression values
|
||||
COMPRESSIONS = {
|
||||
'RAW': 0,
|
||||
'RLE8': 1,
|
||||
|
@ -79,12 +80,14 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
# read bmp header size @offset 14 (this is part of the header size)
|
||||
file_info['header_size'] = i32(read(4))
|
||||
file_info['direction'] = -1
|
||||
# --------------------- If requested, read header at a specific position
|
||||
|
||||
# -------------------- If requested, read header at a specific position
|
||||
# read the rest of the bmp header, without its size
|
||||
header_data = ImageFile._safe_read(self.fp,
|
||||
file_info['header_size'] - 4)
|
||||
# --------------------------------------------------- IBM OS/2 Bitmap v1
|
||||
# ------ This format has different offsets because of width/height types
|
||||
|
||||
# -------------------------------------------------- IBM OS/2 Bitmap v1
|
||||
# ----- This format has different offsets because of width/height types
|
||||
if file_info['header_size'] == 12:
|
||||
file_info['width'] = i16(header_data[0:2])
|
||||
file_info['height'] = i16(header_data[2:4])
|
||||
|
@ -92,8 +95,10 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
file_info['bits'] = i16(header_data[6:8])
|
||||
file_info['compression'] = self.RAW
|
||||
file_info['palette_padding'] = 3
|
||||
# ---------------------------------------------- Windows Bitmap v2 to v5
|
||||
elif file_info['header_size'] in (40, 64, 108, 124): # v3, OS/2 v2, v4, v5
|
||||
|
||||
# --------------------------------------------- Windows Bitmap v2 to v5
|
||||
# v3, OS/2 v2, v4, v5
|
||||
elif file_info['header_size'] in (40, 64, 108, 124):
|
||||
if file_info['header_size'] >= 40: # v3 and OS/2
|
||||
file_info['y_flip'] = i8(header_data[7]) == 0xff
|
||||
file_info['direction'] = 1 if file_info['y_flip'] else -1
|
||||
|
@ -119,12 +124,15 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
'g_mask',
|
||||
'b_mask',
|
||||
'a_mask']):
|
||||
file_info[mask] = i32(header_data[36+idx*4:40+idx*4])
|
||||
file_info[mask] = i32(
|
||||
header_data[36 + idx * 4:40 + idx * 4]
|
||||
)
|
||||
else:
|
||||
# 40 byte headers only have the three components in the
|
||||
# bitfields masks,
|
||||
# ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx
|
||||
# See also https://github.com/python-pillow/Pillow/issues/1293
|
||||
# bitfields masks, ref:
|
||||
# https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx
|
||||
# See also
|
||||
# https://github.com/python-pillow/Pillow/issues/1293
|
||||
# There is a 4th component in the RGBQuad, in the alpha
|
||||
# location, but it is listed as a reserved component,
|
||||
# and it is not generally an alpha channel
|
||||
|
@ -141,20 +149,27 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
else:
|
||||
raise IOError("Unsupported BMP header type (%d)" %
|
||||
file_info['header_size'])
|
||||
|
||||
# ------------------ Special case : header is reported 40, which
|
||||
# ---------------------- is shorter than real size for bpp >= 16
|
||||
self._size = file_info['width'], file_info['height']
|
||||
# -------- If color count was not found in the header, compute from bits
|
||||
file_info['colors'] = file_info['colors'] if file_info.get('colors', 0) else (1 << file_info['bits'])
|
||||
# -------------------------------- Check abnormal values for DOS attacks
|
||||
|
||||
# ------- If color count was not found in the header, compute from bits
|
||||
file_info["colors"] = (file_info["colors"]
|
||||
if file_info.get("colors", 0)
|
||||
else (1 << file_info["bits"]))
|
||||
|
||||
# ------------------------------- Check abnormal values for DOS attacks
|
||||
if file_info['width'] * file_info['height'] > 2**31:
|
||||
raise IOError("Unsupported BMP Size: (%dx%d)" % self.size)
|
||||
# ----------------------- Check bit depth for unusual unsupported values
|
||||
|
||||
# ---------------------- Check bit depth for unusual unsupported values
|
||||
self.mode, raw_mode = BIT2MODE.get(file_info['bits'], (None, None))
|
||||
if self.mode is None:
|
||||
raise IOError("Unsupported BMP pixel depth (%d)"
|
||||
% file_info['bits'])
|
||||
# ----------------- Process BMP with Bitfields compression (not palette)
|
||||
|
||||
# ---------------- Process BMP with Bitfields compression (not palette)
|
||||
if file_info['compression'] == self.BITFIELDS:
|
||||
SUPPORTED = {
|
||||
32: [(0xff0000, 0xff00, 0xff, 0x0),
|
||||
|
@ -176,7 +191,9 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
if file_info['bits'] in SUPPORTED:
|
||||
if file_info['bits'] == 32 and \
|
||||
file_info['rgba_mask'] in SUPPORTED[file_info['bits']]:
|
||||
raw_mode = MASK_MODES[(file_info['bits'], file_info['rgba_mask'])]
|
||||
raw_mode = MASK_MODES[
|
||||
(file_info["bits"], file_info["rgba_mask"])
|
||||
]
|
||||
self.mode = "RGBA" if raw_mode in ("BGRA",) else self.mode
|
||||
elif (file_info['bits'] in (24, 16) and
|
||||
file_info['rgb_mask'] in SUPPORTED[file_info['bits']]):
|
||||
|
@ -193,9 +210,11 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
else:
|
||||
raise IOError("Unsupported BMP compression (%d)" %
|
||||
file_info['compression'])
|
||||
# ---------------- Once the header is processed, process the palette/LUT
|
||||
|
||||
# --------------- Once the header is processed, process the palette/LUT
|
||||
if self.mode == "P": # Paletted for 1, 4 and 8 bit images
|
||||
# ----------------------------------------------------- 1-bit images
|
||||
|
||||
# ---------------------------------------------------- 1-bit images
|
||||
if not (0 < file_info['colors'] <= 65536):
|
||||
raise IOError("Unsupported BMP Palette size (%d)" %
|
||||
file_info['colors'])
|
||||
|
@ -205,12 +224,14 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
greyscale = True
|
||||
indices = (0, 255) if file_info['colors'] == 2 else \
|
||||
list(range(file_info['colors']))
|
||||
# ------------------ Check if greyscale and ignore palette if so
|
||||
|
||||
# ----------------- Check if greyscale and ignore palette if so
|
||||
for ind, val in enumerate(indices):
|
||||
rgb = palette[ind*padding:ind*padding + 3]
|
||||
if rgb != o8(val) * 3:
|
||||
greyscale = False
|
||||
# -------- If all colors are grey, white or black, ditch palette
|
||||
|
||||
# ------- If all colors are grey, white or black, ditch palette
|
||||
if greyscale:
|
||||
self.mode = "1" if file_info['colors'] == 2 else "L"
|
||||
raw_mode = self.mode
|
||||
|
@ -219,7 +240,7 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
self.palette = ImagePalette.raw(
|
||||
"BGRX" if padding == 4 else "BGR", palette)
|
||||
|
||||
# ----------------------------- Finally set the tile data for the plugin
|
||||
# ---------------------------- Finally set the tile data for the plugin
|
||||
self.info['compression'] = file_info['compression']
|
||||
self.tile = [
|
||||
('raw',
|
||||
|
@ -243,9 +264,9 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
self._bitmap(offset=offset)
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# =============================================================================
|
||||
# Image plugin for the DIB format (BMP alias)
|
||||
# ==============================================================================
|
||||
# =============================================================================
|
||||
class DibImageFile(BmpImageFile):
|
||||
|
||||
format = "DIB"
|
||||
|
|
|
@ -59,7 +59,8 @@ class GdImageFile(ImageFile.ImageFile):
|
|||
if tindex < 256:
|
||||
self.info["transparency"] = tindex
|
||||
|
||||
self.palette = ImagePalette.raw("XBGR", s[7+trueColorOffset+4:7+trueColorOffset+4+256*4])
|
||||
self.palette = ImagePalette.raw(
|
||||
"XBGR", s[7+trueColorOffset+4:7+trueColorOffset+4+256*4])
|
||||
|
||||
self.tile = [("raw", (0, 0)+self.size, 7+trueColorOffset+4+256*4,
|
||||
("L", 0, 1))]
|
||||
|
|
|
@ -727,7 +727,7 @@ def getProfileInfo(profile):
|
|||
# add an extra newline to preserve pyCMS compatibility
|
||||
# Python, not C. the white point bits weren't working well,
|
||||
# so skipping.
|
||||
# // info was description \r\n\r\n copyright \r\n\r\n K007 tag \r\n\r\n whitepoint
|
||||
# info was description \r\n\r\n copyright \r\n\r\n K007 tag \r\n\r\n whitepoint
|
||||
description = profile.profile.product_description
|
||||
cpright = profile.profile.product_copyright
|
||||
arr = []
|
||||
|
|
|
@ -87,7 +87,10 @@ def getrgb(color):
|
|||
int((int(m.group(3)) * 255) / 100.0 + 0.5)
|
||||
)
|
||||
|
||||
m = re.match(r"hsl\(\s*(\d+\.?\d*)\s*,\s*(\d+\.?\d*)%\s*,\s*(\d+\.?\d*)%\s*\)$", color)
|
||||
m = re.match(
|
||||
r"hsl\(\s*(\d+\.?\d*)\s*,\s*(\d+\.?\d*)%\s*,\s*(\d+\.?\d*)%\s*\)$",
|
||||
color,
|
||||
)
|
||||
if m:
|
||||
from colorsys import hls_to_rgb
|
||||
rgb = hls_to_rgb(
|
||||
|
@ -101,7 +104,10 @@ def getrgb(color):
|
|||
int(rgb[2] * 255 + 0.5)
|
||||
)
|
||||
|
||||
m = re.match(r"hs[bv]\(\s*(\d+\.?\d*)\s*,\s*(\d+\.?\d*)%\s*,\s*(\d+\.?\d*)%\s*\)$", color)
|
||||
m = re.match(
|
||||
r"hs[bv]\(\s*(\d+\.?\d*)\s*,\s*(\d+\.?\d*)%\s*,\s*(\d+\.?\d*)%\s*\)$",
|
||||
color,
|
||||
)
|
||||
if m:
|
||||
from colorsys import hsv_to_rgb
|
||||
rgb = hsv_to_rgb(
|
||||
|
|
|
@ -54,7 +54,8 @@ def grabclipboard():
|
|||
fh, filepath = tempfile.mkstemp('.jpg')
|
||||
os.close(fh)
|
||||
commands = [
|
||||
"set theFile to (open for access POSIX file \""+filepath+"\" with write permission)",
|
||||
"set theFile to (open for access POSIX file \""
|
||||
+ filepath + "\" with write permission)",
|
||||
"try",
|
||||
" write (the clipboard as JPEG picture) to theFile",
|
||||
"end try",
|
||||
|
|
|
@ -62,7 +62,8 @@ The tables format between im.quantization and quantization in presets differ in
|
|||
You can convert the dict format to the preset format with the
|
||||
`JpegImagePlugin.convert_dict_qtables(dict_qtables)` function.
|
||||
|
||||
Libjpeg ref.: https://web.archive.org/web/20120328125543/http://www.jpegcameras.com/libjpeg/libjpeg-3.html
|
||||
Libjpeg ref.:
|
||||
https://web.archive.org/web/20120328125543/http://www.jpegcameras.com/libjpeg/libjpeg-3.html
|
||||
|
||||
"""
|
||||
|
||||
|
|
|
@ -386,7 +386,8 @@ def pdf_repr(x):
|
|||
|
||||
|
||||
class PdfParser:
|
||||
"""Based on https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
|
||||
"""Based on
|
||||
https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
|
||||
Supports PDF up to 1.4
|
||||
"""
|
||||
|
||||
|
@ -863,7 +864,8 @@ class PdfParser:
|
|||
raise PdfFormatError(
|
||||
"unrecognized object: " + repr(data[offset:offset+32]))
|
||||
|
||||
re_lit_str_token = re.compile(br"(\\[nrtbf()\\])|(\\[0-9]{1,3})|(\\(\r\n|\r|\n))|(\r\n|\r|\n)|(\()|(\))")
|
||||
re_lit_str_token = re.compile(
|
||||
br"(\\[nrtbf()\\])|(\\[0-9]{1,3})|(\\(\r\n|\r|\n))|(\r\n|\r|\n)|(\()|(\))")
|
||||
escaped_chars = {
|
||||
b"n": b"\n",
|
||||
b"r": b"\r",
|
||||
|
|
|
@ -74,7 +74,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %s""
|
|||
|
||||
|
||||
def build_one(py_ver, compiler, bit):
|
||||
# UNDONE virtual envs if we're not running on appveyor
|
||||
# UNDONE virtual envs if we're not running on AppVeyor
|
||||
args = {}
|
||||
args.update(compiler)
|
||||
if 'PYTHON' in os.environ:
|
||||
|
@ -97,6 +97,8 @@ def build_one(py_ver, compiler, bit):
|
|||
else:
|
||||
args['imaging_libs'] = ''
|
||||
|
||||
args['vc_setup'] = vc_setup(compiler, bit)
|
||||
|
||||
script = r"""
|
||||
setlocal EnableDelayedExpansion
|
||||
call "%%ProgramFiles%%\Microsoft SDKs\Windows\%(env_version)s\Bin\SetEnv.Cmd" /Release %(env_flags)s
|
||||
|
@ -105,7 +107,7 @@ set LIB=%%LIB%%;%%INCLIB%%\%(inc_dir)s
|
|||
set INCLUDE=%%INCLUDE%%;%%INCLIB%%\%(inc_dir)s;%%INCLIB%%\tcl%(tcl_ver)s\include
|
||||
|
||||
setlocal
|
||||
set LIB=%%LIB%%;C:\Python%(py_ver)s\tcl""" + vc_setup(compiler, bit) + r"""
|
||||
set LIB=%%LIB%%;C:\Python%(py_ver)s\tcl%(vc_setup)s
|
||||
call %(python_path)s\%(executable)s setup.py %(imaging_libs)s %%BLDOPT%%
|
||||
endlocal
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user