本文整理汇总了Python中PIL.Image.register_mime方法的典型用法代码示例。如果您正苦于以下问题:Python Image.register_mime方法的具体用法?Python Image.register_mime怎么用?Python Image.register_mime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PIL.Image
的用法示例。
在下文中一共展示了Image.register_mime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_imagefield_annotate_with_bitmap_image_after_clean
# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import register_mime [as 别名]
def test_imagefield_annotate_with_bitmap_image_after_clean(self):
"""
This also tests the situation when Pillow doesn't detect the MIME type
of the image (#24948).
"""
from PIL.BmpImagePlugin import BmpImageFile
try:
Image.register_mime(BmpImageFile.format, None)
f = ImageField()
img_path = get_img_path('filepath_test_files/1x1.bmp')
with open(img_path, 'rb') as img_file:
img_data = img_file.read()
img_file = SimpleUploadedFile('1x1.bmp', img_data)
img_file.content_type = 'text/plain'
uploaded_file = f.clean(img_file)
self.assertEqual('BMP', uploaded_file.image.format)
self.assertIsNone(uploaded_file.content_type)
finally:
Image.register_mime(BmpImageFile.format, 'image/bmp')