本文整理匯總了Python中PIL.Image.DecompressionBombWarning方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.DecompressionBombWarning方法的具體用法?Python Image.DecompressionBombWarning怎麽用?Python Image.DecompressionBombWarning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PIL.Image
的用法示例。
在下文中一共展示了Image.DecompressionBombWarning方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_crop_decompression_checks
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import DecompressionBombWarning [as 別名]
def test_crop_decompression_checks(self):
im = Image.new("RGB", (100, 100))
good_values = ((-9999, -9999, -9990, -9990),
(-999, -999, -990, -990))
warning_values = ((-160, -160, 99, 99),
(160, 160, -99, -99))
error_values = ((-99909, -99990, 99999, 99999),
(99909, 99990, -99999, -99999))
for value in good_values:
self.assertEqual(im.crop(value).size, (9, 9))
for value in warning_values:
self.assert_warning(Image.DecompressionBombWarning, im.crop, value)
for value in error_values:
with self.assertRaises(Image.DecompressionBombError):
im.crop(value)
示例2: test_warning
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import DecompressionBombWarning [as 別名]
def test_warning(self):
# Set limit to trigger warning on the test file
Image.MAX_IMAGE_PIXELS = 128 * 128 - 1
self.assertEqual(Image.MAX_IMAGE_PIXELS, 128 * 128 - 1)
self.assert_warning(Image.DecompressionBombWarning,
Image.open, TEST_FILE)
示例3: testEnlargeCrop
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import DecompressionBombWarning [as 別名]
def testEnlargeCrop(self):
# Crops can extend the extents, therefore we should have the
# same decompression bomb warnings on them.
box = (0, 0, self.src.width * 2, self.src.height * 2)
self.assert_warning(Image.DecompressionBombWarning,
self.src.crop, box)
示例4: ignore_warnings
# 需要導入模塊: from PIL import Image [as 別名]
# 或者: from PIL.Image import DecompressionBombWarning [as 別名]
def ignore_warnings():
"""Sets a warning filter for pillow's annoying ``DecompressionBombWarning``
"""
import warnings
from PIL import Image
warnings.simplefilter(action='ignore', category=Image.DecompressionBombWarning)