mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Fix some Landscape.io errors and warnings
This commit is contained in:
parent
485ce69702
commit
ae7b765b53
|
@ -184,7 +184,6 @@ class PngInfo:
|
||||||
tkey = tkey.encode("utf-8", "strict")
|
tkey = tkey.encode("utf-8", "strict")
|
||||||
|
|
||||||
if zip:
|
if zip:
|
||||||
import zlib
|
|
||||||
self.add(b"iTXt", key + b"\0\x01\0" + lang + b"\0" + tkey + b"\0" +
|
self.add(b"iTXt", key + b"\0\x01\0" + lang + b"\0" + tkey + b"\0" +
|
||||||
zlib.compress(value))
|
zlib.compress(value))
|
||||||
else:
|
else:
|
||||||
|
@ -206,7 +205,6 @@ class PngInfo:
|
||||||
key = key.encode('latin-1', 'strict')
|
key = key.encode('latin-1', 'strict')
|
||||||
|
|
||||||
if zip:
|
if zip:
|
||||||
import zlib
|
|
||||||
self.add(b"zTXt", key + b"\0\0" + zlib.compress(value))
|
self.add(b"zTXt", key + b"\0\0" + zlib.compress(value))
|
||||||
else:
|
else:
|
||||||
self.add(b"tEXt", key + b"\0" + value)
|
self.add(b"tEXt", key + b"\0" + value)
|
||||||
|
@ -359,7 +357,6 @@ class PngStream(ChunkStream):
|
||||||
if comp_method != 0:
|
if comp_method != 0:
|
||||||
raise SyntaxError("Unknown compression method %s in zTXt chunk" %
|
raise SyntaxError("Unknown compression method %s in zTXt chunk" %
|
||||||
comp_method)
|
comp_method)
|
||||||
import zlib
|
|
||||||
try:
|
try:
|
||||||
v = zlib.decompress(v[1:])
|
v = zlib.decompress(v[1:])
|
||||||
except zlib.error:
|
except zlib.error:
|
||||||
|
@ -390,7 +387,6 @@ class PngStream(ChunkStream):
|
||||||
return s
|
return s
|
||||||
if cf != 0:
|
if cf != 0:
|
||||||
if cm == 0:
|
if cm == 0:
|
||||||
import zlib
|
|
||||||
try:
|
try:
|
||||||
v = zlib.decompress(v)
|
v = zlib.decompress(v)
|
||||||
except zlib.error:
|
except zlib.error:
|
||||||
|
|
|
@ -175,10 +175,10 @@ def fromstring(data):
|
||||||
return Image.open(BytesIO(data))
|
return Image.open(BytesIO(data))
|
||||||
|
|
||||||
|
|
||||||
def tostring(im, format, **options):
|
def tostring(im, string_format, **options):
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
out = BytesIO()
|
out = BytesIO()
|
||||||
im.save(out, format, **options)
|
im.save(out, string_format, **options)
|
||||||
return out.getvalue()
|
return out.getvalue()
|
||||||
|
|
||||||
|
|
||||||
|
@ -207,7 +207,6 @@ def command_succeeds(cmd):
|
||||||
Runs the command, which must be a list of strings. Returns True if the
|
Runs the command, which must be a list of strings. Returns True if the
|
||||||
command succeeds, or False if an OSError was raised by subprocess.Popen.
|
command succeeds, or False if an OSError was raised by subprocess.Popen.
|
||||||
"""
|
"""
|
||||||
import os
|
|
||||||
import subprocess
|
import subprocess
|
||||||
with open(os.devnull, 'w') as f:
|
with open(os.devnull, 'w') as f:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -166,7 +166,6 @@ class TestFileEps(PillowTestCase):
|
||||||
self._test_readline(t, ending)
|
self._test_readline(t, ending)
|
||||||
|
|
||||||
def _test_readline_io(self, test_string, ending):
|
def _test_readline_io(self, test_string, ending):
|
||||||
import io
|
|
||||||
if str is bytes:
|
if str is bytes:
|
||||||
t = io.StringIO(unicode(test_string))
|
t = io.StringIO(unicode(test_string))
|
||||||
else:
|
else:
|
||||||
|
@ -205,7 +204,7 @@ class TestFileEps(PillowTestCase):
|
||||||
|
|
||||||
for ending in line_endings:
|
for ending in line_endings:
|
||||||
s = ending.join(strings)
|
s = ending.join(strings)
|
||||||
# Native python versions will pass these endings.
|
# Native Python versions will pass these endings.
|
||||||
#self._test_readline_stringio(s, ending)
|
#self._test_readline_stringio(s, ending)
|
||||||
#self._test_readline_io(s, ending)
|
#self._test_readline_io(s, ending)
|
||||||
#self._test_readline_file_universal(s, ending)
|
#self._test_readline_file_universal(s, ending)
|
||||||
|
@ -217,7 +216,7 @@ class TestFileEps(PillowTestCase):
|
||||||
# they're not likely to be used
|
# they're not likely to be used
|
||||||
s = ending.join(strings)
|
s = ending.join(strings)
|
||||||
|
|
||||||
# Native python versions may fail on these endings.
|
# Native Python versions may fail on these endings.
|
||||||
#self._test_readline_stringio(s, ending)
|
#self._test_readline_stringio(s, ending)
|
||||||
#self._test_readline_io(s, ending)
|
#self._test_readline_io(s, ending)
|
||||||
#self._test_readline_file_universal(s, ending)
|
#self._test_readline_file_universal(s, ending)
|
||||||
|
|
|
@ -7,36 +7,36 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
def test_sanity(self):
|
def test_sanity(self):
|
||||||
|
|
||||||
file = self.tempfile("temp.tif")
|
filename = self.tempfile("temp.tif")
|
||||||
|
|
||||||
hopper("RGB").save(file)
|
hopper("RGB").save(filename)
|
||||||
|
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
im.load()
|
im.load()
|
||||||
self.assertEqual(im.mode, "RGB")
|
self.assertEqual(im.mode, "RGB")
|
||||||
self.assertEqual(im.size, (128, 128))
|
self.assertEqual(im.size, (128, 128))
|
||||||
self.assertEqual(im.format, "TIFF")
|
self.assertEqual(im.format, "TIFF")
|
||||||
|
|
||||||
hopper("1").save(file)
|
hopper("1").save(filename)
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
|
|
||||||
hopper("L").save(file)
|
hopper("L").save(filename)
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
|
|
||||||
hopper("P").save(file)
|
hopper("P").save(filename)
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
|
|
||||||
hopper("RGB").save(file)
|
hopper("RGB").save(filename)
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
|
|
||||||
hopper("I").save(file)
|
hopper("I").save(filename)
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
|
|
||||||
def test_mac_tiff(self):
|
def test_mac_tiff(self):
|
||||||
# Read RGBa images from Mac OS X [@PIL136]
|
# Read RGBa images from Mac OS X [@PIL136]
|
||||||
|
|
||||||
file = "Tests/images/pil136.tiff"
|
filename = "Tests/images/pil136.tiff"
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
|
|
||||||
self.assertEqual(im.mode, "RGBA")
|
self.assertEqual(im.mode, "RGBA")
|
||||||
self.assertEqual(im.size, (55, 43))
|
self.assertEqual(im.size, (55, 43))
|
||||||
|
@ -50,8 +50,8 @@ class TestFileTiff(PillowTestCase):
|
||||||
if "jpeg_decoder" not in codecs:
|
if "jpeg_decoder" not in codecs:
|
||||||
self.skipTest("jpeg support not available")
|
self.skipTest("jpeg support not available")
|
||||||
|
|
||||||
file = "Tests/images/pil168.tif"
|
filename = "Tests/images/pil168.tif"
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
|
|
||||||
self.assertEqual(im.mode, "RGB")
|
self.assertEqual(im.mode, "RGB")
|
||||||
self.assertEqual(im.size, (256, 256))
|
self.assertEqual(im.size, (256, 256))
|
||||||
|
@ -66,8 +66,8 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
def test_xyres_tiff(self):
|
def test_xyres_tiff(self):
|
||||||
from PIL.TiffImagePlugin import X_RESOLUTION, Y_RESOLUTION
|
from PIL.TiffImagePlugin import X_RESOLUTION, Y_RESOLUTION
|
||||||
file = "Tests/images/pil168.tif"
|
filename = "Tests/images/pil168.tif"
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
assert isinstance(im.tag.tags[X_RESOLUTION][0], tuple)
|
assert isinstance(im.tag.tags[X_RESOLUTION][0], tuple)
|
||||||
assert isinstance(im.tag.tags[Y_RESOLUTION][0], tuple)
|
assert isinstance(im.tag.tags[Y_RESOLUTION][0], tuple)
|
||||||
# Try to read a file where X,Y_RESOLUTION are ints
|
# Try to read a file where X,Y_RESOLUTION are ints
|
||||||
|
@ -169,8 +169,8 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
def test___str__(self):
|
def test___str__(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
file = "Tests/images/pil136.tiff"
|
filename = "Tests/images/pil136.tiff"
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
ret = str(im.ifd)
|
ret = str(im.ifd)
|
||||||
|
@ -186,8 +186,8 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
def test__delitem__(self):
|
def test__delitem__(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
file = "Tests/images/pil136.tiff"
|
filename = "Tests/images/pil136.tiff"
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
len_before = len(im.ifd.as_dict())
|
len_before = len(im.ifd.as_dict())
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
|
@ -199,7 +199,6 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
def test_load_byte(self):
|
def test_load_byte(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
from PIL import TiffImagePlugin
|
|
||||||
ifd = TiffImagePlugin.ImageFileDirectory()
|
ifd = TiffImagePlugin.ImageFileDirectory()
|
||||||
data = b"abc"
|
data = b"abc"
|
||||||
|
|
||||||
|
@ -211,7 +210,6 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
def test_load_string(self):
|
def test_load_string(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
from PIL import TiffImagePlugin
|
|
||||||
ifd = TiffImagePlugin.ImageFileDirectory()
|
ifd = TiffImagePlugin.ImageFileDirectory()
|
||||||
data = b"abc\0"
|
data = b"abc\0"
|
||||||
|
|
||||||
|
@ -223,7 +221,6 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
def test_load_float(self):
|
def test_load_float(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
from PIL import TiffImagePlugin
|
|
||||||
ifd = TiffImagePlugin.ImageFileDirectory()
|
ifd = TiffImagePlugin.ImageFileDirectory()
|
||||||
data = b"abcdabcd"
|
data = b"abcdabcd"
|
||||||
|
|
||||||
|
@ -235,7 +232,6 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
def test_load_double(self):
|
def test_load_double(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
from PIL import TiffImagePlugin
|
|
||||||
ifd = TiffImagePlugin.ImageFileDirectory()
|
ifd = TiffImagePlugin.ImageFileDirectory()
|
||||||
data = b"abcdefghabcdefgh"
|
data = b"abcdefghabcdefgh"
|
||||||
|
|
||||||
|
@ -247,8 +243,8 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
def test_seek(self):
|
def test_seek(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
file = "Tests/images/pil136.tiff"
|
filename = "Tests/images/pil136.tiff"
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
im.seek(-1)
|
im.seek(-1)
|
||||||
|
@ -258,8 +254,8 @@ class TestFileTiff(PillowTestCase):
|
||||||
|
|
||||||
def test_seek_eof(self):
|
def test_seek_eof(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
file = "Tests/images/pil136.tiff"
|
filename = "Tests/images/pil136.tiff"
|
||||||
im = Image.open(file)
|
im = Image.open(filename)
|
||||||
self.assertEqual(im.tell(), 0)
|
self.assertEqual(im.tell(), 0)
|
||||||
|
|
||||||
# Act / Assert
|
# Act / Assert
|
||||||
|
|
|
@ -4,7 +4,7 @@ from PIL import Image
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PIL import _webp
|
from PIL import _webp
|
||||||
except:
|
except ImportError:
|
||||||
# Skip in setUp()
|
# Skip in setUp()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class TestFileWebp(PillowTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
try:
|
try:
|
||||||
from PIL import _webp
|
from PIL import _webp
|
||||||
except:
|
except ImportError:
|
||||||
self.skipTest('WebP support not installed')
|
self.skipTest('WebP support not installed')
|
||||||
|
|
||||||
def test_version(self):
|
def test_version(self):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from PIL import Image
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PIL import _webp
|
from PIL import _webp
|
||||||
except:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
# Skip in setUp()
|
# Skip in setUp()
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class TestFileWebpAlpha(PillowTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
try:
|
try:
|
||||||
from PIL import _webp
|
from PIL import _webp
|
||||||
except:
|
except ImportError:
|
||||||
self.skipTest('WebP support not installed')
|
self.skipTest('WebP support not installed')
|
||||||
|
|
||||||
if _webp.WebPDecoderBuggyAlpha(self):
|
if _webp.WebPDecoderBuggyAlpha(self):
|
||||||
|
@ -80,8 +80,8 @@ class TestFileWebpAlpha(PillowTestCase):
|
||||||
self.assertEqual(image.mode, "RGBA")
|
self.assertEqual(image.mode, "RGBA")
|
||||||
self.assertEqual(image.size, (10, 10))
|
self.assertEqual(image.size, (10, 10))
|
||||||
self.assertEqual(image.format, "WEBP")
|
self.assertEqual(image.format, "WEBP")
|
||||||
image.load
|
image.load()
|
||||||
image.getdata
|
image.getdata()
|
||||||
|
|
||||||
self.assert_image_similar(image, pil_image, 1.0)
|
self.assert_image_similar(image, pil_image, 1.0)
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ class MorphTests(PillowTestCase):
|
||||||
'corner', 'dilation4', 'dilation8',
|
'corner', 'dilation4', 'dilation8',
|
||||||
'erosion4', 'erosion8', 'edge'):
|
'erosion4', 'erosion8', 'edge'):
|
||||||
lb = ImageMorph.LutBuilder(op_name=op)
|
lb = ImageMorph.LutBuilder(op_name=op)
|
||||||
lut = lb.build_lut(self)
|
lut = lb.build_lut()
|
||||||
with open('Tests/images/%s.lut' % op, 'wb') as f:
|
with open('Tests/images/%s.lut' % op, 'wb') as f:
|
||||||
f.write(lut)
|
f.write(lut)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user