mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-11 00:32:27 +03:00
commit
12028c9789
|
@ -32,7 +32,7 @@ class TestFileTar(PillowTestCase):
|
||||||
tar.close()
|
tar.close()
|
||||||
|
|
||||||
def test_contextmanager(self):
|
def test_contextmanager(self):
|
||||||
with TarIO.TarIO(TEST_TAR_FILE, 'hopper.jpg') as tar:
|
with TarIO.TarIO(TEST_TAR_FILE, 'hopper.jpg'):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -429,7 +429,8 @@ class TestFileTiff(PillowTestCase):
|
||||||
"Tests/images/tiff_adobe_deflate.png")
|
"Tests/images/tiff_adobe_deflate.png")
|
||||||
|
|
||||||
def test_strip_planar_raw(self):
|
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"
|
infile = "Tests/images/tiff_strip_planar_raw.tif"
|
||||||
im = Image.open(infile)
|
im = Image.open(infile)
|
||||||
|
|
||||||
|
@ -445,7 +446,8 @@ class TestFileTiff(PillowTestCase):
|
||||||
"Tests/images/tiff_adobe_deflate.png")
|
"Tests/images/tiff_adobe_deflate.png")
|
||||||
|
|
||||||
def test_tiled_planar_raw(self):
|
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
|
# tiff_tiled_raw.tif tiff_tiled_planar_raw.tiff
|
||||||
infile = "Tests/images/tiff_tiled_planar_raw.tif"
|
infile = "Tests/images/tiff_tiled_planar_raw.tif"
|
||||||
im = Image.open(infile)
|
im = Image.open(infile)
|
||||||
|
|
|
@ -15,8 +15,10 @@ class TestUnsupportedWebp(PillowTestCase):
|
||||||
WebPImagePlugin.SUPPORTED = False
|
WebPImagePlugin.SUPPORTED = False
|
||||||
|
|
||||||
file_path = "Tests/images/hopper.webp"
|
file_path = "Tests/images/hopper.webp"
|
||||||
self.assert_warning(UserWarning,
|
self.assert_warning(
|
||||||
lambda: self.assertRaises(IOError, Image.open, file_path))
|
UserWarning,
|
||||||
|
lambda: self.assertRaises(IOError, Image.open, file_path)
|
||||||
|
)
|
||||||
|
|
||||||
if HAVE_WEBP:
|
if HAVE_WEBP:
|
||||||
WebPImagePlugin.SUPPORTED = True
|
WebPImagePlugin.SUPPORTED = True
|
||||||
|
|
|
@ -139,7 +139,6 @@ class TestImage(PillowTestCase):
|
||||||
# Act/Assert
|
# Act/Assert
|
||||||
# Shouldn't cause AttributeError (#774)
|
# Shouldn't cause AttributeError (#774)
|
||||||
self.assertFalse(item is None)
|
self.assertFalse(item is None)
|
||||||
self.assertFalse(item == None)
|
|
||||||
self.assertFalse(item == num)
|
self.assertFalse(item == num)
|
||||||
|
|
||||||
def test_expand_x(self):
|
def test_expand_x(self):
|
||||||
|
|
|
@ -102,6 +102,7 @@ class TestImagePutPixel(AccessTest):
|
||||||
|
|
||||||
self.assert_image_equal(im1, im2)
|
self.assert_image_equal(im1, im2)
|
||||||
|
|
||||||
|
|
||||||
class TestImageGetPixel(AccessTest):
|
class TestImageGetPixel(AccessTest):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def color(mode):
|
def color(mode):
|
||||||
|
|
|
@ -106,7 +106,7 @@ class TestImageFilter(PillowTestCase):
|
||||||
def test_consistency_3x3(self):
|
def test_consistency_3x3(self):
|
||||||
source = Image.open("Tests/images/hopper.bmp")
|
source = Image.open("Tests/images/hopper.bmp")
|
||||||
reference = Image.open("Tests/images/hopper_emboss.bmp")
|
reference = Image.open("Tests/images/hopper_emboss.bmp")
|
||||||
kernel = ImageFilter.Kernel((3, 3),
|
kernel = ImageFilter.Kernel((3, 3), # noqa: E127
|
||||||
(-1, -1, 0,
|
(-1, -1, 0,
|
||||||
-1, 0, 1,
|
-1, 0, 1,
|
||||||
0, 1, 1), .3)
|
0, 1, 1), .3)
|
||||||
|
@ -122,7 +122,7 @@ class TestImageFilter(PillowTestCase):
|
||||||
def test_consistency_5x5(self):
|
def test_consistency_5x5(self):
|
||||||
source = Image.open("Tests/images/hopper.bmp")
|
source = Image.open("Tests/images/hopper.bmp")
|
||||||
reference = Image.open("Tests/images/hopper_emboss_more.bmp")
|
reference = Image.open("Tests/images/hopper_emboss_more.bmp")
|
||||||
kernel = ImageFilter.Kernel((5, 5),
|
kernel = ImageFilter.Kernel((5, 5), # noqa: E127
|
||||||
(-1, -1, -1, -1, 0,
|
(-1, -1, -1, -1, 0,
|
||||||
-1, -1, -1, 0, 1,
|
-1, -1, -1, 0, 1,
|
||||||
-1, -1, 0, 1, 1,
|
-1, -1, 0, 1, 1,
|
||||||
|
|
|
@ -152,7 +152,7 @@ class TestImageTransform(PillowTestCase):
|
||||||
]
|
]
|
||||||
|
|
||||||
# Yeah. Watch some JIT optimize this out.
|
# Yeah. Watch some JIT optimize this out.
|
||||||
pattern = None
|
pattern = None # noqa: F841
|
||||||
|
|
||||||
self.test_mesh()
|
self.test_mesh()
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ try:
|
||||||
from PIL import ImageCms
|
from PIL import ImageCms
|
||||||
from PIL.ImageCms import ImageCmsProfile
|
from PIL.ImageCms import ImageCmsProfile
|
||||||
ImageCms.core.profile_open
|
ImageCms.core.profile_open
|
||||||
except ImportError as v:
|
except ImportError:
|
||||||
# Skipped via setUp()
|
# Skipped via setUp()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -294,7 +294,14 @@ class TestImageCms(PillowTestCase):
|
||||||
p.blue_primary,
|
p.blue_primary,
|
||||||
((0.14306641366715667, 0.06060790921083026, 0.7140960805782015),
|
((0.14306641366715667, 0.06060790921083026, 0.7140960805782015),
|
||||||
(0.15588475410450106, 0.06603820408959558, 0.06060790921083026)))
|
(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.assertIsNone(p.chromaticity)
|
||||||
self.assertEqual(p.clut, {
|
self.assertEqual(p.clut, {
|
||||||
0: (False, False, True),
|
0: (False, False, True),
|
||||||
|
@ -402,7 +409,7 @@ class TestImageCms(PillowTestCase):
|
||||||
def create_test_image():
|
def create_test_image():
|
||||||
# set up test image with something interesting in the tested aux
|
# set up test image with something interesting in the tested aux
|
||||||
# channel.
|
# channel.
|
||||||
nine_grid_deltas = [
|
nine_grid_deltas = [ # noqa: E128
|
||||||
(-1, -1), (-1, 0), (-1, 1),
|
(-1, -1), (-1, 0), (-1, 1),
|
||||||
(0, -1), (0, 0), (0, 1),
|
(0, -1), (0, 0), (0, 1),
|
||||||
(1, -1), (1, 0), (1, 1),
|
(1, -1), (1, 0), (1, 1),
|
||||||
|
@ -421,7 +428,11 @@ class TestImageCms(PillowTestCase):
|
||||||
)
|
)
|
||||||
channel_data = Image.new(channel_type, channel_pattern.size)
|
channel_data = Image.new(channel_type, channel_pattern.size)
|
||||||
for delta in nine_grid_deltas:
|
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)
|
chans.append(channel_data)
|
||||||
return Image.merge(mode, chans)
|
return Image.merge(mode, chans)
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ if ImageQt.qt_is_installed:
|
||||||
|
|
||||||
pixmap1 = QtGui.QPixmap.fromImage(qimage)
|
pixmap1 = QtGui.QPixmap.fromImage(qimage)
|
||||||
|
|
||||||
QHBoxLayout(self)
|
QHBoxLayout(self) # hbox
|
||||||
|
|
||||||
lbl = QLabel(self)
|
lbl = QLabel(self)
|
||||||
# Segfault in the problem
|
# Segfault in the problem
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
# sys.path.insert(0, os.path.abspath('.'))
|
# sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
|
||||||
|
import sphinx_rtd_theme
|
||||||
|
|
||||||
|
import PIL
|
||||||
|
|
||||||
# -- General configuration ------------------------------------------------
|
# -- General configuration ------------------------------------------------
|
||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
# If your documentation needs a minimal Sphinx version, state it here.
|
||||||
|
@ -52,7 +56,6 @@ author = u'Fredrik Lundh, Alex Clark and Contributors'
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
import PIL
|
|
||||||
version = PIL.__version__
|
version = PIL.__version__
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = PIL.__version__
|
release = PIL.__version__
|
||||||
|
@ -107,7 +110,6 @@ todo_include_todos = False
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
|
|
||||||
import sphinx_rtd_theme
|
|
||||||
html_theme = "sphinx_rtd_theme"
|
html_theme = "sphinx_rtd_theme"
|
||||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||||
|
|
||||||
|
@ -268,7 +270,8 @@ man_pages = [
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
(master_doc, 'PillowPILFork', u'Pillow (PIL Fork) Documentation',
|
(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'),
|
'Miscellaneous'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ class DdsImageFile(ImageFile.ImageFile):
|
||||||
self.mode = "RGBA"
|
self.mode = "RGBA"
|
||||||
|
|
||||||
pitch, depth, mipmaps = struct.unpack("<3I", header.read(12))
|
pitch, depth, mipmaps = struct.unpack("<3I", header.read(12))
|
||||||
reserved = struct.unpack("<11I", header.read(44))
|
struct.unpack("<11I", header.read(44)) # reserved
|
||||||
|
|
||||||
# pixel format
|
# pixel format
|
||||||
pfsize, pfflags = struct.unpack("<2I", header.read(8))
|
pfsize, pfflags = struct.unpack("<2I", header.read(8))
|
||||||
|
@ -235,10 +235,8 @@ class DdsImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
if fourcc == b"DXT1":
|
if fourcc == b"DXT1":
|
||||||
self.decoder = "DXT1"
|
self.decoder = "DXT1"
|
||||||
codec = _dxt1
|
|
||||||
elif fourcc == b"DXT5":
|
elif fourcc == b"DXT5":
|
||||||
self.decoder = "DXT5"
|
self.decoder = "DXT5"
|
||||||
codec = _dxt5
|
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("Unimplemented pixel format %r" % fourcc)
|
raise NotImplementedError("Unimplemented pixel format %r" % fourcc)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from PIL import Image, ImageDraw, ImageFilter, ImageMath
|
from PIL import Image
|
||||||
from PIL import features
|
from PIL import features
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -26,6 +26,7 @@ def testimage():
|
||||||
"""
|
"""
|
||||||
PIL lets you create in-memory images with various pixel types:
|
PIL lets you create in-memory images with various pixel types:
|
||||||
|
|
||||||
|
>>> from PIL import Image, ImageDraw, ImageFilter, ImageMath
|
||||||
>>> im = Image.new("1", (128, 128)) # monochrome
|
>>> im = Image.new("1", (128, 128)) # monochrome
|
||||||
>>> _info(im)
|
>>> _info(im)
|
||||||
(None, '1', (128, 128))
|
(None, '1', (128, 128))
|
||||||
|
|
|
@ -50,16 +50,17 @@ def _accept(prefix):
|
||||||
return prefix[:2] == b"BM"
|
return prefix[:2] == b"BM"
|
||||||
|
|
||||||
|
|
||||||
# ==============================================================================
|
# =============================================================================
|
||||||
# Image plugin for the Windows BMP format.
|
# Image plugin for the Windows BMP format.
|
||||||
# ==============================================================================
|
# =============================================================================
|
||||||
class BmpImageFile(ImageFile.ImageFile):
|
class BmpImageFile(ImageFile.ImageFile):
|
||||||
""" Image plugin for the Windows Bitmap format (BMP) """
|
""" Image plugin for the Windows Bitmap format (BMP) """
|
||||||
|
|
||||||
# -------------------------------------------------------------- Description
|
# ------------------------------------------------------------- Description
|
||||||
format_description = "Windows Bitmap"
|
format_description = "Windows Bitmap"
|
||||||
format = "BMP"
|
format = "BMP"
|
||||||
# --------------------------------------------------- BMP Compression values
|
|
||||||
|
# -------------------------------------------------- BMP Compression values
|
||||||
COMPRESSIONS = {
|
COMPRESSIONS = {
|
||||||
'RAW': 0,
|
'RAW': 0,
|
||||||
'RLE8': 1,
|
'RLE8': 1,
|
||||||
|
@ -79,12 +80,14 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
# read bmp header size @offset 14 (this is part of the header size)
|
# read bmp header size @offset 14 (this is part of the header size)
|
||||||
file_info['header_size'] = i32(read(4))
|
file_info['header_size'] = i32(read(4))
|
||||||
file_info['direction'] = -1
|
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
|
# read the rest of the bmp header, without its size
|
||||||
header_data = ImageFile._safe_read(self.fp,
|
header_data = ImageFile._safe_read(self.fp,
|
||||||
file_info['header_size'] - 4)
|
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:
|
if file_info['header_size'] == 12:
|
||||||
file_info['width'] = i16(header_data[0:2])
|
file_info['width'] = i16(header_data[0:2])
|
||||||
file_info['height'] = i16(header_data[2:4])
|
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['bits'] = i16(header_data[6:8])
|
||||||
file_info['compression'] = self.RAW
|
file_info['compression'] = self.RAW
|
||||||
file_info['palette_padding'] = 3
|
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
|
if file_info['header_size'] >= 40: # v3 and OS/2
|
||||||
file_info['y_flip'] = i8(header_data[7]) == 0xff
|
file_info['y_flip'] = i8(header_data[7]) == 0xff
|
||||||
file_info['direction'] = 1 if file_info['y_flip'] else -1
|
file_info['direction'] = 1 if file_info['y_flip'] else -1
|
||||||
|
@ -119,12 +124,15 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
'g_mask',
|
'g_mask',
|
||||||
'b_mask',
|
'b_mask',
|
||||||
'a_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:
|
else:
|
||||||
# 40 byte headers only have the three components in the
|
# 40 byte headers only have the three components in the
|
||||||
# bitfields masks,
|
# bitfields masks, ref:
|
||||||
# ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx
|
# https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx
|
||||||
# See also https://github.com/python-pillow/Pillow/issues/1293
|
# See also
|
||||||
|
# https://github.com/python-pillow/Pillow/issues/1293
|
||||||
# There is a 4th component in the RGBQuad, in the alpha
|
# There is a 4th component in the RGBQuad, in the alpha
|
||||||
# location, but it is listed as a reserved component,
|
# location, but it is listed as a reserved component,
|
||||||
# and it is not generally an alpha channel
|
# and it is not generally an alpha channel
|
||||||
|
@ -141,20 +149,27 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
else:
|
else:
|
||||||
raise IOError("Unsupported BMP header type (%d)" %
|
raise IOError("Unsupported BMP header type (%d)" %
|
||||||
file_info['header_size'])
|
file_info['header_size'])
|
||||||
|
|
||||||
# ------------------ Special case : header is reported 40, which
|
# ------------------ Special case : header is reported 40, which
|
||||||
# ---------------------- is shorter than real size for bpp >= 16
|
# ---------------------- is shorter than real size for bpp >= 16
|
||||||
self._size = file_info['width'], file_info['height']
|
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'])
|
# ------- If color count was not found in the header, compute from bits
|
||||||
# -------------------------------- Check abnormal values for DOS attacks
|
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:
|
if file_info['width'] * file_info['height'] > 2**31:
|
||||||
raise IOError("Unsupported BMP Size: (%dx%d)" % self.size)
|
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))
|
self.mode, raw_mode = BIT2MODE.get(file_info['bits'], (None, None))
|
||||||
if self.mode is None:
|
if self.mode is None:
|
||||||
raise IOError("Unsupported BMP pixel depth (%d)"
|
raise IOError("Unsupported BMP pixel depth (%d)"
|
||||||
% file_info['bits'])
|
% file_info['bits'])
|
||||||
# ----------------- Process BMP with Bitfields compression (not palette)
|
|
||||||
|
# ---------------- Process BMP with Bitfields compression (not palette)
|
||||||
if file_info['compression'] == self.BITFIELDS:
|
if file_info['compression'] == self.BITFIELDS:
|
||||||
SUPPORTED = {
|
SUPPORTED = {
|
||||||
32: [(0xff0000, 0xff00, 0xff, 0x0),
|
32: [(0xff0000, 0xff00, 0xff, 0x0),
|
||||||
|
@ -176,7 +191,9 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
if file_info['bits'] in SUPPORTED:
|
if file_info['bits'] in SUPPORTED:
|
||||||
if file_info['bits'] == 32 and \
|
if file_info['bits'] == 32 and \
|
||||||
file_info['rgba_mask'] in SUPPORTED[file_info['bits']]:
|
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
|
self.mode = "RGBA" if raw_mode in ("BGRA",) else self.mode
|
||||||
elif (file_info['bits'] in (24, 16) and
|
elif (file_info['bits'] in (24, 16) and
|
||||||
file_info['rgb_mask'] in SUPPORTED[file_info['bits']]):
|
file_info['rgb_mask'] in SUPPORTED[file_info['bits']]):
|
||||||
|
@ -193,9 +210,11 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
else:
|
else:
|
||||||
raise IOError("Unsupported BMP compression (%d)" %
|
raise IOError("Unsupported BMP compression (%d)" %
|
||||||
file_info['compression'])
|
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
|
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):
|
if not (0 < file_info['colors'] <= 65536):
|
||||||
raise IOError("Unsupported BMP Palette size (%d)" %
|
raise IOError("Unsupported BMP Palette size (%d)" %
|
||||||
file_info['colors'])
|
file_info['colors'])
|
||||||
|
@ -205,12 +224,14 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
greyscale = True
|
greyscale = True
|
||||||
indices = (0, 255) if file_info['colors'] == 2 else \
|
indices = (0, 255) if file_info['colors'] == 2 else \
|
||||||
list(range(file_info['colors']))
|
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):
|
for ind, val in enumerate(indices):
|
||||||
rgb = palette[ind*padding:ind*padding + 3]
|
rgb = palette[ind*padding:ind*padding + 3]
|
||||||
if rgb != o8(val) * 3:
|
if rgb != o8(val) * 3:
|
||||||
greyscale = False
|
greyscale = False
|
||||||
# -------- If all colors are grey, white or black, ditch palette
|
|
||||||
|
# ------- If all colors are grey, white or black, ditch palette
|
||||||
if greyscale:
|
if greyscale:
|
||||||
self.mode = "1" if file_info['colors'] == 2 else "L"
|
self.mode = "1" if file_info['colors'] == 2 else "L"
|
||||||
raw_mode = self.mode
|
raw_mode = self.mode
|
||||||
|
@ -219,7 +240,7 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
self.palette = ImagePalette.raw(
|
self.palette = ImagePalette.raw(
|
||||||
"BGRX" if padding == 4 else "BGR", palette)
|
"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.info['compression'] = file_info['compression']
|
||||||
self.tile = [
|
self.tile = [
|
||||||
('raw',
|
('raw',
|
||||||
|
@ -243,9 +264,9 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
self._bitmap(offset=offset)
|
self._bitmap(offset=offset)
|
||||||
|
|
||||||
|
|
||||||
# ==============================================================================
|
# =============================================================================
|
||||||
# Image plugin for the DIB format (BMP alias)
|
# Image plugin for the DIB format (BMP alias)
|
||||||
# ==============================================================================
|
# =============================================================================
|
||||||
class DibImageFile(BmpImageFile):
|
class DibImageFile(BmpImageFile):
|
||||||
|
|
||||||
format = "DIB"
|
format = "DIB"
|
||||||
|
|
|
@ -118,7 +118,7 @@ class DdsImageFile(ImageFile.ImageFile):
|
||||||
self.mode = "RGBA"
|
self.mode = "RGBA"
|
||||||
|
|
||||||
pitch, depth, mipmaps = struct.unpack("<3I", header.read(12))
|
pitch, depth, mipmaps = struct.unpack("<3I", header.read(12))
|
||||||
reserved = struct.unpack("<11I", header.read(44))
|
struct.unpack("<11I", header.read(44)) # reserved
|
||||||
|
|
||||||
# pixel format
|
# pixel format
|
||||||
pfsize, pfflags = struct.unpack("<2I", header.read(8))
|
pfsize, pfflags = struct.unpack("<2I", header.read(8))
|
||||||
|
|
|
@ -125,10 +125,11 @@ def Ghostscript(tile, size, fp, scale=1):
|
||||||
"-dSAFER", # safe mode
|
"-dSAFER", # safe mode
|
||||||
"-sDEVICE=ppmraw", # ppm driver
|
"-sDEVICE=ppmraw", # ppm driver
|
||||||
"-sOutputFile=%s" % outfile, # output file
|
"-sOutputFile=%s" % outfile, # output file
|
||||||
"-c", "%d %d translate" % (-bbox[0], -bbox[1]),
|
|
||||||
# adjust for image origin
|
# adjust for image origin
|
||||||
|
"-c", "%d %d translate" % (-bbox[0], -bbox[1]),
|
||||||
"-f", infile, # input file
|
"-f", infile, # input file
|
||||||
"-c", "showpage", # showpage (see: https://bugs.ghostscript.com/show_bug.cgi?id=698272)
|
# showpage (see https://bugs.ghostscript.com/show_bug.cgi?id=698272)
|
||||||
|
"-c", "showpage",
|
||||||
]
|
]
|
||||||
|
|
||||||
if gs_windows_binary is not None:
|
if gs_windows_binary is not None:
|
||||||
|
|
|
@ -66,8 +66,8 @@ class FtexImageFile(ImageFile.ImageFile):
|
||||||
format_description = "Texture File Format (IW2:EOC)"
|
format_description = "Texture File Format (IW2:EOC)"
|
||||||
|
|
||||||
def _open(self):
|
def _open(self):
|
||||||
magic = struct.unpack("<I", self.fp.read(4))
|
struct.unpack("<I", self.fp.read(4)) # magic
|
||||||
version = struct.unpack("<i", self.fp.read(4))
|
struct.unpack("<i", self.fp.read(4)) # version
|
||||||
self._size = struct.unpack("<2i", self.fp.read(8))
|
self._size = struct.unpack("<2i", self.fp.read(8))
|
||||||
mipmap_count, format_count = struct.unpack("<2i", self.fp.read(8))
|
mipmap_count, format_count = struct.unpack("<2i", self.fp.read(8))
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,8 @@ class GdImageFile(ImageFile.ImageFile):
|
||||||
if tindex < 256:
|
if tindex < 256:
|
||||||
self.info["transparency"] = tindex
|
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,
|
self.tile = [("raw", (0, 0)+self.size, 7+trueColorOffset+4+256*4,
|
||||||
("L", 0, 1))]
|
("L", 0, 1))]
|
||||||
|
|
|
@ -153,7 +153,7 @@ class ImImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
m = split.match(s)
|
m = split.match(s)
|
||||||
except re.error as v:
|
except re.error:
|
||||||
raise SyntaxError("not an IM file")
|
raise SyntaxError("not an IM file")
|
||||||
|
|
||||||
if m:
|
if m:
|
||||||
|
|
|
@ -34,6 +34,36 @@ import logging
|
||||||
import warnings
|
import warnings
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
try:
|
||||||
|
import builtins
|
||||||
|
except ImportError:
|
||||||
|
import __builtin__
|
||||||
|
builtins = __builtin__
|
||||||
|
|
||||||
|
from . import ImageMode
|
||||||
|
from ._binary import i8
|
||||||
|
from ._util import isPath, isStringType, deferred_error
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import io
|
||||||
|
import struct
|
||||||
|
import atexit
|
||||||
|
|
||||||
|
# type stuff
|
||||||
|
import numbers
|
||||||
|
try:
|
||||||
|
# Python 3
|
||||||
|
from collections.abc import Callable
|
||||||
|
except ImportError:
|
||||||
|
# Python 2.7
|
||||||
|
from collections import Callable
|
||||||
|
|
||||||
|
|
||||||
|
# Silence warnings
|
||||||
|
assert VERSION
|
||||||
|
assert PILLOW_VERSION
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,39 +134,13 @@ except ImportError as v:
|
||||||
# see docs/porting.rst
|
# see docs/porting.rst
|
||||||
raise
|
raise
|
||||||
|
|
||||||
try:
|
|
||||||
import builtins
|
|
||||||
except ImportError:
|
|
||||||
import __builtin__
|
|
||||||
builtins = __builtin__
|
|
||||||
|
|
||||||
from . import ImageMode
|
|
||||||
from ._binary import i8
|
|
||||||
from ._util import isPath, isStringType, deferred_error
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import io
|
|
||||||
import struct
|
|
||||||
import atexit
|
|
||||||
|
|
||||||
# type stuff
|
|
||||||
import numbers
|
|
||||||
try:
|
|
||||||
# Python 3
|
|
||||||
from collections.abc import Callable
|
|
||||||
except ImportError:
|
|
||||||
# Python 2.7
|
|
||||||
from collections import Callable
|
|
||||||
|
|
||||||
|
|
||||||
# works everywhere, win for pypy, not cpython
|
# works everywhere, win for pypy, not cpython
|
||||||
USE_CFFI_ACCESS = hasattr(sys, 'pypy_version_info')
|
USE_CFFI_ACCESS = hasattr(sys, 'pypy_version_info')
|
||||||
try:
|
try:
|
||||||
import cffi
|
import cffi
|
||||||
HAS_CFFI = True
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_CFFI = False
|
cffi = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -376,26 +380,32 @@ def preinit():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from . import BmpImagePlugin
|
from . import BmpImagePlugin
|
||||||
|
assert BmpImagePlugin
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
from . import GifImagePlugin
|
from . import GifImagePlugin
|
||||||
|
assert GifImagePlugin
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
from . import JpegImagePlugin
|
from . import JpegImagePlugin
|
||||||
|
assert JpegImagePlugin
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
from . import PpmImagePlugin
|
from . import PpmImagePlugin
|
||||||
|
assert PpmImagePlugin
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
from . import PngImagePlugin
|
from . import PngImagePlugin
|
||||||
|
assert PngImagePlugin
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
# try:
|
# try:
|
||||||
# import TiffImagePlugin
|
# import TiffImagePlugin
|
||||||
|
# assert TiffImagePlugin
|
||||||
# except ImportError:
|
# except ImportError:
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
|
@ -833,7 +843,7 @@ class Image(object):
|
||||||
self.palette.mode = "RGBA"
|
self.palette.mode = "RGBA"
|
||||||
|
|
||||||
if self.im:
|
if self.im:
|
||||||
if HAS_CFFI and USE_CFFI_ACCESS:
|
if cffi and USE_CFFI_ACCESS:
|
||||||
if self.pyaccess:
|
if self.pyaccess:
|
||||||
return self.pyaccess
|
return self.pyaccess
|
||||||
from . import PyAccess
|
from . import PyAccess
|
||||||
|
|
|
@ -727,7 +727,7 @@ def getProfileInfo(profile):
|
||||||
# add an extra newline to preserve pyCMS compatibility
|
# add an extra newline to preserve pyCMS compatibility
|
||||||
# Python, not C. the white point bits weren't working well,
|
# Python, not C. the white point bits weren't working well,
|
||||||
# so skipping.
|
# 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
|
description = profile.profile.product_description
|
||||||
cpright = profile.profile.product_copyright
|
cpright = profile.profile.product_copyright
|
||||||
arr = []
|
arr = []
|
||||||
|
|
|
@ -87,7 +87,10 @@ def getrgb(color):
|
||||||
int((int(m.group(3)) * 255) / 100.0 + 0.5)
|
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:
|
if m:
|
||||||
from colorsys import hls_to_rgb
|
from colorsys import hls_to_rgb
|
||||||
rgb = hls_to_rgb(
|
rgb = hls_to_rgb(
|
||||||
|
@ -101,7 +104,10 @@ def getrgb(color):
|
||||||
int(rgb[2] * 255 + 0.5)
|
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:
|
if m:
|
||||||
from colorsys import hsv_to_rgb
|
from colorsys import hsv_to_rgb
|
||||||
rgb = hsv_to_rgb(
|
rgb = hsv_to_rgb(
|
||||||
|
|
|
@ -54,7 +54,8 @@ def grabclipboard():
|
||||||
fh, filepath = tempfile.mkstemp('.jpg')
|
fh, filepath = tempfile.mkstemp('.jpg')
|
||||||
os.close(fh)
|
os.close(fh)
|
||||||
commands = [
|
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",
|
"try",
|
||||||
" write (the clipboard as JPEG picture) to theFile",
|
" write (the clipboard as JPEG picture) to theFile",
|
||||||
"end try",
|
"end try",
|
||||||
|
|
|
@ -26,15 +26,15 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
from . import Image
|
||||||
|
|
||||||
if sys.version_info.major > 2:
|
if sys.version_info.major > 2:
|
||||||
import tkinter
|
import tkinter
|
||||||
else:
|
else:
|
||||||
import Tkinter as tkinter
|
import Tkinter as tkinter
|
||||||
|
|
||||||
from . import Image
|
|
||||||
from io import BytesIO
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# Check for Tkinter interface hooks
|
# Check for Tkinter interface hooks
|
||||||
|
|
|
@ -578,7 +578,7 @@ RAWMODE = {
|
||||||
"YCbCr": "YCbCr",
|
"YCbCr": "YCbCr",
|
||||||
}
|
}
|
||||||
|
|
||||||
zigzag_index = (0, 1, 5, 6, 14, 15, 27, 28,
|
zigzag_index = (0, 1, 5, 6, 14, 15, 27, 28, # noqa: E128
|
||||||
2, 4, 7, 13, 16, 26, 29, 42,
|
2, 4, 7, 13, 16, 26, 29, 42,
|
||||||
3, 8, 12, 17, 25, 30, 41, 43,
|
3, 8, 12, 17, 25, 30, 41, 43,
|
||||||
9, 11, 18, 24, 31, 40, 44, 53,
|
9, 11, 18, 24, 31, 40, 44, 53,
|
||||||
|
|
|
@ -62,11 +62,12 @@ The tables format between im.quantization and quantization in presets differ in
|
||||||
You can convert the dict format to the preset format with the
|
You can convert the dict format to the preset format with the
|
||||||
`JpegImagePlugin.convert_dict_qtables(dict_qtables)` function.
|
`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
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
presets = {
|
presets = { # noqa: E128
|
||||||
'web_low': {'subsampling': 2, # "4:2:0"
|
'web_low': {'subsampling': 2, # "4:2:0"
|
||||||
'quantization': [
|
'quantization': [
|
||||||
[20, 16, 25, 39, 50, 46, 62, 68,
|
[20, 16, 25, 39, 50, 46, 62, 68,
|
||||||
|
|
|
@ -12,7 +12,7 @@ from ._binary import o8, o16be as o16b
|
||||||
|
|
||||||
__version__ = "1.0"
|
__version__ = "1.0"
|
||||||
|
|
||||||
_Palm8BitColormapValues = (
|
_Palm8BitColormapValues = ( # noqa: E131
|
||||||
(255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255),
|
(255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255),
|
||||||
(255, 51, 255), (255, 0, 255), (255, 255, 204), (255, 204, 204),
|
(255, 51, 255), (255, 0, 255), (255, 255, 204), (255, 204, 204),
|
||||||
(255, 153, 204), (255, 102, 204), (255, 51, 204), (255, 0, 204),
|
(255, 153, 204), (255, 102, 204), (255, 51, 204), (255, 0, 204),
|
||||||
|
|
|
@ -230,7 +230,7 @@ class PcfFontFile(FontFile.FontFile):
|
||||||
firstCol, lastCol = i16(fp.read(2)), i16(fp.read(2))
|
firstCol, lastCol = i16(fp.read(2)), i16(fp.read(2))
|
||||||
firstRow, lastRow = i16(fp.read(2)), i16(fp.read(2))
|
firstRow, lastRow = i16(fp.read(2)), i16(fp.read(2))
|
||||||
|
|
||||||
default = i16(fp.read(2))
|
i16(fp.read(2)) # default
|
||||||
|
|
||||||
nencoding = (lastCol - firstCol + 1) * (lastRow - firstRow + 1)
|
nencoding = (lastCol - firstCol + 1) * (lastRow - firstRow + 1)
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,8 @@ def pdf_repr(x):
|
||||||
|
|
||||||
|
|
||||||
class PdfParser:
|
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
|
Supports PDF up to 1.4
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -863,7 +864,8 @@ class PdfParser:
|
||||||
raise PdfFormatError(
|
raise PdfFormatError(
|
||||||
"unrecognized object: " + repr(data[offset:offset+32]))
|
"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 = {
|
escaped_chars = {
|
||||||
b"n": b"\n",
|
b"n": b"\n",
|
||||||
b"r": b"\r",
|
b"r": b"\r",
|
||||||
|
|
|
@ -92,7 +92,7 @@ class PsdImageFile(ImageFile.ImageFile):
|
||||||
# load resources
|
# load resources
|
||||||
end = self.fp.tell() + size
|
end = self.fp.tell() + size
|
||||||
while self.fp.tell() < end:
|
while self.fp.tell() < end:
|
||||||
signature = read(4)
|
read(4) # signature
|
||||||
id = i16(read(2))
|
id = i16(read(2))
|
||||||
name = read(i8(read(1)))
|
name = read(i8(read(1)))
|
||||||
if not (len(name) & 1):
|
if not (len(name) & 1):
|
||||||
|
@ -207,17 +207,13 @@ def _layerinfo(file):
|
||||||
mode = None # unknown
|
mode = None # unknown
|
||||||
|
|
||||||
# skip over blend flags and extra information
|
# skip over blend flags and extra information
|
||||||
filler = read(12)
|
read(12) # filler
|
||||||
name = ""
|
name = ""
|
||||||
size = i32(read(4))
|
size = i32(read(4))
|
||||||
combined = 0
|
combined = 0
|
||||||
if size:
|
if size:
|
||||||
length = i32(read(4))
|
length = i32(read(4))
|
||||||
if length:
|
if length:
|
||||||
mask_y = i32(read(4))
|
|
||||||
mask_x = i32(read(4))
|
|
||||||
mask_h = i32(read(4)) - mask_y
|
|
||||||
mask_w = i32(read(4)) - mask_x
|
|
||||||
file.seek(length - 16, 1)
|
file.seek(length - 16, 1)
|
||||||
combined += length + 4
|
combined += length + 4
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ from . import Image, ImageFile
|
||||||
try:
|
try:
|
||||||
from . import _webp
|
from . import _webp
|
||||||
SUPPORTED = True
|
SUPPORTED = True
|
||||||
except ImportError as e:
|
except ImportError:
|
||||||
SUPPORTED = False
|
SUPPORTED = False
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
|
|
@ -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):
|
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 = {}
|
||||||
args.update(compiler)
|
args.update(compiler)
|
||||||
if 'PYTHON' in os.environ:
|
if 'PYTHON' in os.environ:
|
||||||
|
@ -97,6 +97,8 @@ def build_one(py_ver, compiler, bit):
|
||||||
else:
|
else:
|
||||||
args['imaging_libs'] = ''
|
args['imaging_libs'] = ''
|
||||||
|
|
||||||
|
args['vc_setup'] = vc_setup(compiler, bit)
|
||||||
|
|
||||||
script = r"""
|
script = r"""
|
||||||
setlocal EnableDelayedExpansion
|
setlocal EnableDelayedExpansion
|
||||||
call "%%ProgramFiles%%\Microsoft SDKs\Windows\%(env_version)s\Bin\SetEnv.Cmd" /Release %(env_flags)s
|
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
|
set INCLUDE=%%INCLUDE%%;%%INCLIB%%\%(inc_dir)s;%%INCLIB%%\tcl%(tcl_ver)s\include
|
||||||
|
|
||||||
setlocal
|
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%%
|
call %(python_path)s\%(executable)s setup.py %(imaging_libs)s %%BLDOPT%%
|
||||||
endlocal
|
endlocal
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user