當前位置: 首頁>>代碼示例>>Python>>正文


Python Image.DecompressionBombWarning方法代碼示例

本文整理匯總了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) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:24,代碼來源:test_decompression_bomb.py

示例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) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:9,代碼來源:test_decompression_bomb.py

示例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) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:8,代碼來源:test_decompression_bomb.py

示例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) 
開發者ID:OpenGeoVis,項目名稱:omfvista,代碼行數:8,代碼來源:__init__.py


注:本文中的PIL.Image.DecompressionBombWarning方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。