mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-26 00:30:33 +03:00
commit
c32a8257d7
|
@ -151,7 +151,7 @@ def Ghostscript(tile, size, fp, scale=1):
|
|||
os.unlink(outfile)
|
||||
if infile_temp:
|
||||
os.unlink(infile_temp)
|
||||
except:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
return im
|
||||
|
|
|
@ -518,7 +518,7 @@ def _save_netpbm(im, fp, filename):
|
|||
|
||||
try:
|
||||
os.unlink(file)
|
||||
except:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -550,7 +550,7 @@ class Image(object):
|
|||
try:
|
||||
self.fp.close()
|
||||
except Exception as msg:
|
||||
logger.debug("Error closing: %s" % msg)
|
||||
logger.debug("Error closing: %s", msg)
|
||||
|
||||
# Instead of simply setting to None, we're setting up a
|
||||
# deferred error that will better explain that the core image
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# below for the original description.
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
|
||||
DESCRIPTION = """
|
||||
pyCMS
|
||||
|
@ -240,7 +241,6 @@ def get_display_profile(handle=None):
|
|||
:returns: None if the profile is not known.
|
||||
"""
|
||||
|
||||
import sys
|
||||
if sys.platform == "win32":
|
||||
from PIL import ImageWin
|
||||
if isinstance(handle, ImageWin.HDC):
|
||||
|
@ -943,7 +943,6 @@ def versions():
|
|||
(pyCMS) Fetches versions.
|
||||
"""
|
||||
|
||||
import sys
|
||||
return (
|
||||
VERSION, core.littlecms_version,
|
||||
sys.version.split()[0], Image.VERSION
|
||||
|
@ -954,10 +953,9 @@ def versions():
|
|||
if __name__ == "__main__":
|
||||
# create a cheap manual from the __doc__ strings for the functions above
|
||||
|
||||
from PIL import ImageCms
|
||||
print(__doc__)
|
||||
|
||||
for f in dir(ImageCms):
|
||||
for f in dir(sys.modules[__name__]):
|
||||
doc = None
|
||||
try:
|
||||
exec("doc = %s.__doc__" % (f))
|
||||
|
|
|
@ -200,7 +200,6 @@ class MorphOp(object):
|
|||
|
||||
if image.mode != 'L':
|
||||
raise Exception('Image must be binary, meaning it must use mode L')
|
||||
return
|
||||
outimage = Image.new(image.mode, image.size, None)
|
||||
count = _imagingmorph.apply(
|
||||
bytes(self.lut), image.im.id, outimage.im.id)
|
||||
|
@ -217,7 +216,6 @@ class MorphOp(object):
|
|||
|
||||
if image.mode != 'L':
|
||||
raise Exception('Image must be binary, meaning it must use mode L')
|
||||
return
|
||||
return _imagingmorph.match(bytes(self.lut), image.im.id)
|
||||
|
||||
def get_on_pixels(self, image):
|
||||
|
@ -228,7 +226,6 @@ class MorphOp(object):
|
|||
|
||||
if image.mode != 'L':
|
||||
raise Exception('Image must be binary, meaning it must use mode L')
|
||||
return
|
||||
return _imagingmorph.get_on_pixels(image.im.id)
|
||||
|
||||
def load_lut(self, filename):
|
||||
|
|
|
@ -179,7 +179,7 @@ class IptcImageFile(ImageFile.ImageFile):
|
|||
finally:
|
||||
try:
|
||||
os.unlink(outfile)
|
||||
except:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ class JpegImageFile(ImageFile.ImageFile):
|
|||
finally:
|
||||
try:
|
||||
os.unlink(path)
|
||||
except:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
self.mode = self.im.mode
|
||||
|
@ -699,7 +699,7 @@ def _save_cjpeg(im, fp, filename):
|
|||
subprocess.check_call(["cjpeg", "-outfile", filename, tempfile])
|
||||
try:
|
||||
os.unlink(tempfile)
|
||||
except:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -152,7 +152,8 @@ class PILDriver(object):
|
|||
self.push(Image.composite(image1, image2, mask))
|
||||
|
||||
def do_merge(self):
|
||||
"""usage: merge <string:mode> <image:pic1> [<image:pic2> [<image:pic3> [<image:pic4>]]]
|
||||
"""usage: merge <string:mode> <image:pic1>
|
||||
[<image:pic2> [<image:pic3> [<image:pic4>]]]
|
||||
|
||||
Merge top-of stack images in a way described by the mode.
|
||||
"""
|
||||
|
@ -181,7 +182,8 @@ class PILDriver(object):
|
|||
self.dup()
|
||||
|
||||
def do_crop(self):
|
||||
"""usage: crop <int:left> <int:upper> <int:right> <int:lower> <image:pic1>
|
||||
"""usage: crop <int:left> <int:upper> <int:right> <int:lower>
|
||||
<image:pic1>
|
||||
|
||||
Crop and push a rectangular region from the current image.
|
||||
"""
|
||||
|
@ -243,7 +245,8 @@ class PILDriver(object):
|
|||
self.push(image.offset(xoff, yoff))
|
||||
|
||||
def do_paste(self):
|
||||
"""usage: paste <image:figure> <int:xoffset> <int:yoffset> <image:ground>
|
||||
"""usage: paste <image:figure> <int:xoffset> <int:yoffset>
|
||||
<image:ground>
|
||||
|
||||
Paste figure image into ground with upper left at given offsets.
|
||||
"""
|
||||
|
|
|
@ -6,7 +6,8 @@ iterations = 5000
|
|||
|
||||
|
||||
"""
|
||||
When run on a system without the jpeg leak fixes, the valgrind runs look like this.
|
||||
When run on a system without the jpeg leak fixes,
|
||||
the valgrind runs look like this.
|
||||
|
||||
NOSE_PROCESSES=0 NOSE_TIMEOUT=600 valgrind --tool=massif \
|
||||
python test-installed.py -s -v Tests/check_jpeg_leaks.py
|
||||
|
|
|
@ -110,7 +110,7 @@ class TestFileTiff(PillowTestCase):
|
|||
def test_bad_exif(self):
|
||||
i = Image.open('Tests/images/hopper_bad_exif.jpg')
|
||||
try:
|
||||
self.assert_warning(UserWarning, lambda: i._getexif())
|
||||
self.assert_warning(UserWarning, i._getexif)
|
||||
except struct.error:
|
||||
self.fail(
|
||||
"Bad EXIF data passed incorrect values to _binary unpack")
|
||||
|
|
|
@ -24,7 +24,7 @@ class TestImageSequence(PillowTestCase):
|
|||
|
||||
self.assertRaises(AttributeError, lambda: ImageSequence.Iterator(0))
|
||||
|
||||
def _test_multipage_tiff(self, dbg=False):
|
||||
def _test_multipage_tiff(self):
|
||||
im = Image.open('Tests/images/multipage.tiff')
|
||||
for index, frame in enumerate(ImageSequence.Iterator(im)):
|
||||
frame.load()
|
||||
|
@ -32,8 +32,7 @@ class TestImageSequence(PillowTestCase):
|
|||
frame.convert('RGB')
|
||||
|
||||
def test_tiff(self):
|
||||
# self._test_multipage_tiff(True)
|
||||
self._test_multipage_tiff(False)
|
||||
self._test_multipage_tiff()
|
||||
|
||||
def test_libtiff(self):
|
||||
codecs = dir(Image.core)
|
||||
|
@ -42,8 +41,7 @@ class TestImageSequence(PillowTestCase):
|
|||
self.skipTest("tiff support not available")
|
||||
|
||||
TiffImagePlugin.READ_LIBTIFF = True
|
||||
# self._test_multipage_tiff(True)
|
||||
self._test_multipage_tiff(False)
|
||||
self._test_multipage_tiff()
|
||||
TiffImagePlugin.READ_LIBTIFF = False
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -114,7 +114,7 @@ class TestImageWinDib(PillowTestCase):
|
|||
|
||||
# Act/Assert
|
||||
self.assertRaises(Exception, dib.tostring)
|
||||
self.assertRaises(Exception, lambda: dib.fromstring(test_buffer))
|
||||
self.assertRaises(Exception, dib.fromstring)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -104,7 +104,7 @@ if sys.platform.startswith('win32'):
|
|||
DeleteObject(dib)
|
||||
DeleteDC(hdc)
|
||||
|
||||
reloaded = Image.open(BytesIO(bitmap)).save(opath)
|
||||
Image.open(BytesIO(bitmap)).save(opath)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -206,9 +206,8 @@ if __name__ == "__main__":
|
|||
|
||||
# use doctest to make sure the test program behaves as documented!
|
||||
import doctest
|
||||
import selftest
|
||||
print("Running selftest:")
|
||||
status = doctest.testmod(selftest)
|
||||
status = doctest.testmod(sys.modules[__name__])
|
||||
if status[0]:
|
||||
print("*** %s tests of %d failed." % status)
|
||||
exit_status = 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user