• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python image.ImageSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _get_transformed

    def _get_transformed(self, query, format):
        dst_srs = query.srs
        src_srs = self._best_supported_srs(dst_srs)
        dst_bbox = query.bbox
        src_bbox = dst_srs.transform_bbox_to(src_srs, dst_bbox)
        
        src_width, src_height = src_bbox[2]-src_bbox[0], src_bbox[3]-src_bbox[1]
        ratio = src_width/src_height
        dst_size = query.size
        xres, yres = src_width/dst_size[0], src_height/dst_size[1]
        if xres < yres:
            src_size = dst_size[0], int(dst_size[0]/ratio + 0.5)
        else:
            src_size = int(dst_size[1]*ratio +0.5), dst_size[1]
        
        src_query = MapQuery(src_bbox, src_size, src_srs, format)

        if self.coverage and not self.coverage.contains(src_bbox, src_srs):
            img = self._get_sub_query(src_query, format)
        else:
            resp = self.client.retrieve(src_query, format)
            img = ImageSource(resp, size=src_size, image_opts=self.image_opts)
        
        img = ImageTransformer(src_srs, dst_srs).transform(img, src_bbox, 
            query.size, dst_bbox, self.image_opts)
        
        img.format = format
        return img
开发者ID:cedricmoullet,项目名称:mapproxy,代码行数:28,代码来源:wms.py


示例2: test_output_formats_png24

 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,代码行数:8,代码来源:test_image.py


示例3: test_save_with_unsupported_transparency

    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,代码行数:10,代码来源:test_image.py


示例4: test_from_non_seekable_file

 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,代码行数:13,代码来源:test_image.py


示例5: setup

 def setup(self):
     self.src_img = ImageSource(create_debug_img((200, 200), transparent=False))
     self.src_srs = SRS(31467)
     self.dst_size = (100, 150)
     self.dst_srs = SRS(4326)
     self.dst_bbox = (0.2, 45.1, 8.3, 53.2)
     self.src_bbox = self.dst_srs.transform_bbox_to(self.src_srs, self.dst_bbox)
开发者ID:tjay,项目名称:mapproxy,代码行数:7,代码来源:test_image.py


示例6: TestTransform

class TestTransform(object):
    def setup(self):
        self.src_img = ImageSource(create_debug_img((200, 200), transparent=False))
        self.src_srs = SRS(31467)
        self.dst_size = (100, 150)
        self.dst_srs = SRS(4326)
        self.dst_bbox = (0.2, 45.1, 8.3, 53.2)
        self.src_bbox = self.dst_srs.transform_bbox_to(self.src_srs, self.dst_bbox)
    def test_transform(self, mesh_div=4):
        transformer = ImageTransformer(self.src_srs, self.dst_srs, mesh_div=mesh_div)
        result = transformer.transform(self.src_img, self.src_bbox, self.dst_size, self.dst_bbox,
            image_opts=ImageOptions(resampling='nearest'))
        assert isinstance(result, ImageSource)
        assert result.as_image() != self.src_img.as_image()
        assert result.size == (100, 150)

    def _test_compare_mesh_div(self):
        """
        Create transformations with different div values.
        """
        for div in [1, 2, 4, 6, 8, 12, 16]:
            transformer = ImageTransformer(self.src_srs, self.dst_srs, mesh_div=div)
            result = transformer.transform(self.src_img, self.src_bbox,
                                           self.dst_size, self.dst_bbox)
            result.as_image().save('/tmp/transform-%d.png' % (div,))
开发者ID:tjay,项目名称:mapproxy,代码行数:25,代码来源:test_image.py


示例7: test_converted_output

 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,代码行数:7,代码来源:test_image.py


示例8: test_output_formats_png8

 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,代码行数:6,代码来源:test_image.py


示例9: test_output_formats

 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,代码行数:5,代码来源:test_image.py


示例10: test_from_image

 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,代码行数:5,代码来源:test_image.py


示例11: test_from_file

 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,代码行数:5,代码来源:test_image.py


示例12: test_from_filename

 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,代码行数:4,代码来源:test_image.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python image.SubImageSource类代码示例发布时间:2022-05-27
下一篇:
Python image.make_transparent函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap