当前位置: 首页>>代码示例>>Python>>正文


Python ImageSource.as_buffer方法代码示例

本文整理汇总了Python中mapproxy.image.ImageSource.as_buffer方法的典型用法代码示例。如果您正苦于以下问题:Python ImageSource.as_buffer方法的具体用法?Python ImageSource.as_buffer怎么用?Python ImageSource.as_buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mapproxy.image.ImageSource的用法示例。


在下文中一共展示了ImageSource.as_buffer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_converted_output

# 需要导入模块: from mapproxy.image import ImageSource [as 别名]
# 或者: from mapproxy.image.ImageSource import as_buffer [as 别名]
 def test_converted_output(self):
     ir = ImageSource(self.tmp_filename, (100, 100), PNG_FORMAT)
     assert is_png(ir.as_buffer())
     assert is_jpeg(ir.as_buffer(JPEG_FORMAT))
     assert is_jpeg(ir.as_buffer())
     assert is_tiff(ir.as_buffer(TIFF_FORMAT))
     assert is_tiff(ir.as_buffer())
开发者ID:atrawog,项目名称:mapproxy,代码行数:9,代码来源:test_image.py

示例2: test_from_non_seekable_file

# 需要导入模块: from mapproxy.image import ImageSource [as 别名]
# 或者: from mapproxy.image.ImageSource import as_buffer [as 别名]
 def test_from_non_seekable_file(self):
     with open(self.tmp_filename, 'rb') as tmp_file:
         data = tmp_file.read()
         
     class FileLikeDummy(object):
         # "file" without seek, like urlopen response
         def read(self):
             return data
     
     ir = ImageSource(FileLikeDummy(), 'png')
     assert ir.as_buffer(seekable=True).read() == data
     assert ir.as_image().size == (100, 100)
     assert ir.as_buffer().read() == data
开发者ID:atrawog,项目名称:mapproxy,代码行数:15,代码来源:test_image.py

示例3: test_output_formats_png24

# 需要导入模块: from mapproxy.image import ImageSource [as 别名]
# 或者: from mapproxy.image.ImageSource import as_buffer [as 别名]
 def test_output_formats_png24(self):
     img = Image.new('RGBA', (100, 100))
     image_opts = PNG_FORMAT.copy()
     image_opts.colors = 0 # TODO image_opts
     ir = ImageSource(img, image_opts=image_opts)
     img = Image.open(ir.as_buffer())
     eq_(img.mode, 'RGBA')
     assert img.getpixel((0, 0)) == (0, 0, 0, 0)
开发者ID:atrawog,项目名称:mapproxy,代码行数:10,代码来源:test_image.py

示例4: test_save_with_unsupported_transparency

# 需要导入模块: from mapproxy.image import ImageSource [as 别名]
# 或者: from mapproxy.image.ImageSource import as_buffer [as 别名]
    def test_save_with_unsupported_transparency(self):
        # check if encoding of non-RGB image with tuple as transparency
        # works. workaround for Pillow #2633
        img = Image.new('P', (100, 100))
        img.info['transparency'] = (0, 0, 0)
        image_opts = PNG_FORMAT.copy()

        ir = ImageSource(img, image_opts=image_opts)
        img = Image.open(ir.as_buffer())
        eq_(img.mode, 'P')
开发者ID:LKajan,项目名称:mapproxy,代码行数:12,代码来源:test_image.py

示例5: test_output_formats_png8

# 需要导入模块: from mapproxy.image import ImageSource [as 别名]
# 或者: from mapproxy.image.ImageSource import as_buffer [as 别名]
 def test_output_formats_png8(self):
     img = Image.new('RGBA', (100, 100))
     ir = ImageSource(img, image_opts=PNG_FORMAT)
     img = Image.open(ir.as_buffer(ImageOptions(colors=256, transparent=True, format='image/png')))
     assert img.mode == 'P'
     assert img.getpixel((0, 0)) == 255
开发者ID:atrawog,项目名称:mapproxy,代码行数:8,代码来源:test_image.py

示例6: test_output_formats

# 需要导入模块: from mapproxy.image import ImageSource [as 别名]
# 或者: from mapproxy.image.ImageSource import as_buffer [as 别名]
 def test_output_formats(self):
     img = Image.new('RGB', (100, 100))
     for format in ['png', 'gif', 'tiff', 'jpeg', 'GeoTIFF', 'bmp']:
         ir = ImageSource(img, (100, 100), image_opts=ImageOptions(format=format))
         yield check_format, ir.as_buffer(), format
开发者ID:atrawog,项目名称:mapproxy,代码行数:7,代码来源:test_image.py

示例7: test_from_image

# 需要导入模块: from mapproxy.image import ImageSource [as 别名]
# 或者: from mapproxy.image.ImageSource import as_buffer [as 别名]
 def test_from_image(self):
     img = Image.new('RGBA', (100, 100))
     ir = ImageSource(img, (100, 100), PNG_FORMAT)
     assert ir.as_image() == img
     assert is_png(ir.as_buffer())
开发者ID:atrawog,项目名称:mapproxy,代码行数:7,代码来源:test_image.py

示例8: test_from_file

# 需要导入模块: from mapproxy.image import ImageSource [as 别名]
# 或者: from mapproxy.image.ImageSource import as_buffer [as 别名]
 def test_from_file(self):
     with open(self.tmp_filename, 'rb') as tmp_file:
         ir = ImageSource(tmp_file, 'png')
         assert ir.as_buffer() == tmp_file
         assert ir.as_image().size == (100, 100)
开发者ID:atrawog,项目名称:mapproxy,代码行数:7,代码来源:test_image.py

示例9: test_from_filename

# 需要导入模块: from mapproxy.image import ImageSource [as 别名]
# 或者: from mapproxy.image.ImageSource import as_buffer [as 别名]
 def test_from_filename(self):
     ir = ImageSource(self.tmp_filename, PNG_FORMAT)
     assert is_png(ir.as_buffer())
     assert ir.as_image().size == (100, 100)
开发者ID:atrawog,项目名称:mapproxy,代码行数:6,代码来源:test_image.py


注:本文中的mapproxy.image.ImageSource.as_buffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。