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

Python image.is_png函数代码示例

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

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



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

示例1: test_get_map_uncached

    def test_get_map_uncached(self):
        mbtiles_file = os.path.join(test_config['base_dir'], 'cache.mbtiles')
        tiles_lock_dir = os.path.join(test_config['base_dir'], 'testlockdir')

        assert os.path.exists(mbtiles_file) # already created on startup
        assert not os.path.exists(tiles_lock_dir)

        self.common_map_req.params.bbox = '-180,0,0,80'
        serv = MockServ(port=42423)
        serv.expects('/tiles/01/000/000/000/000/000/001.png')
        serv.returns(create_tmp_image((256, 256)))
        with serv:
            resp = self.app.get(self.common_map_req)
            eq_(resp.content_type, 'image/png')
            data = StringIO(resp.body)
            assert is_png(data)

        # now cached
        resp = self.app.get(self.common_map_req)
        eq_(resp.content_type, 'image/png')
        data = StringIO(resp.body)
        assert is_png(data)

        # custom tile_lock_dir created
        assert os.path.exists(tiles_lock_dir)
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:25,代码来源:test_cache_mbtiles.py


示例2: test_combined_mixed_fwd_req_params

    def test_combined_mixed_fwd_req_params(self):
        # not merged to one request because fwd_req_params are different
        common_params = (r'/service_a?SERVICE=WMS&FORMAT=image%2Fpng'
                                  '&REQUEST=GetMap&HEIGHT=200&SRS=EPSG%3A4326&styles='
                                  '&VERSION=1.1.1&BBOX=9.0,50.0,10.0,51.0'
                                  '&WIDTH=200&transparent=True')

        with tmp_image((200, 200), format='png') as img:
            img = img.read()
            expected_req = [({'path': common_params + '&layers=a_one&TIME=20041012'},
                             {'body': img, 'headers': {'content-type': 'image/png'}}),
                             ({'path': common_params + '&layers=a_two&TIME=20041012&VENDOR=foo'},
                             {'body': img, 'headers': {'content-type': 'image/png'}}),
                             ({'path': common_params + '&layers=a_four'},
                             {'body': img, 'headers': {'content-type': 'image/png'}}),
                            ]

            with mock_httpd(('localhost', 42423), expected_req):
                self.common_map_req.params.layers = 'layer_fwdparams1,single'
                self.common_map_req.params['time'] = '20041012'
                self.common_map_req.params['vendor'] = 'foo'
                self.common_map_req.params.transparent = True
                resp = self.app.get(self.common_map_req)
                resp.content_type = 'image/png'
                data = BytesIO(resp.body)
                assert is_png(data)
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:26,代码来源:test_combined_sources.py


示例3: 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


示例4: test_layers_with_opacity

    def test_layers_with_opacity(self):
        # overlay with opacity -> request should not be combined
        common_params = (r'?SERVICE=WMS&FORMAT=image%2Fpng'
                                  '&REQUEST=GetMap&HEIGHT=200&SRS=EPSG%3A4326&styles='
                                  '&VERSION=1.1.1&BBOX=9.0,50.0,10.0,51.0'
                                  '&WIDTH=200')

        img_bg = create_tmp_image((200, 200), color=(0, 0, 0))
        img_fg = create_tmp_image((200, 200), color=(255, 0, 128))

        expected_req = [
                        ({'path': '/service_a' + common_params + '&layers=a_one'},
                         {'body': img_bg, 'headers': {'content-type': 'image/png'}}),
                        ({'path': '/service_a' + common_params + '&layers=a_two'},
                         {'body': img_fg, 'headers': {'content-type': 'image/png'}}),
                        ]

        with mock_httpd(('localhost', 42423), expected_req):
            self.common_map_req.params.layers = 'opacity_base,opacity_overlay'
            resp = self.app.get(self.common_map_req)
            eq_(resp.content_type, 'image/png')
            data = BytesIO(resp.body)
            assert is_png(data)
            img = Image.open(data)
            eq_(img.getcolors()[0], ((200*200),(127, 0, 64)))
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:25,代码来源:test_combined_sources.py


示例5: test_get_map_uncached

    def test_get_map_uncached(self):
        self.common_map_req.params.bbox = '-180,0,0,80'
        serv = MockServ(port=42423)
        serv.expects('/tiles/01/000/000/000/000/000/001.png')
        serv.returns(create_tmp_image((256, 256)))
        with serv:
            resp = self.app.get(self.common_map_req)
            eq_(resp.content_type, 'image/png')
            data = StringIO(resp.body)
            assert is_png(data)

        # now cached
        resp = self.app.get(self.common_map_req)
        eq_(resp.content_type, 'image/png')
        data = StringIO(resp.body)
        assert is_png(data)
开发者ID:ChrisRenton,项目名称:mapproxy,代码行数:16,代码来源:test_cache_mbtiles.py


示例6: test_get_tile_uncached

 def test_get_tile_uncached(self):
     resp = self.app.get('/tms/1.0.0/wms_cache/0/0/0.jpeg')
     eq_(resp.content_type, 'image/png')
     data = BytesIO(resp.body)
     assert is_png(data)
     img = Image.open(data)
     eq_(img.mode, 'RGBA')
     eq_(img.getcolors(), [(256*256, (255, 255, 255, 0))])
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:8,代码来源:test_seed_only.py


示例7: test_get_map

 def test_get_map(self):
     resp = self.app.get(self.common_map_req)
     eq_(resp.content_type, 'image/png')
     data = BytesIO(resp.body)
     assert is_png(data)
     img = Image.open(data)
     img = img.convert('RGB')
     eq_(img.getcolors(), [(200*200, (255, 0, 0))])
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:8,代码来源:test_mapserver.py


示例8: test_get_map_cached

 def test_get_map_cached(self):
     resp = self.app.get(self.common_map_req)
     eq_(resp.content_type, 'image/png')
     data = BytesIO(resp.body)
     assert is_png(data)
     img = Image.open(data)
     eq_(img.mode, 'RGB')
     # cached image has more that 256 colors, getcolors -> None
     eq_(img.getcolors(), None)
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:9,代码来源:test_seed_only.py


示例9: test_get_map_uncached

 def test_get_map_uncached(self):
     self.common_map_req.params['bbox'] = '10,10,20,20'
     resp = self.app.get(self.common_map_req)
     eq_(resp.content_type, 'image/png')
     data = BytesIO(resp.body)
     assert is_png(data)
     img = Image.open(data)
     eq_(img.mode, 'RGBA')
     eq_(img.getcolors(), [(200*200, (255, 255, 255, 0))])
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:9,代码来源:test_seed_only.py


示例10: test_get_tile_without_caching

    def test_get_tile_without_caching(self):
        with tmp_image((256, 256), format='png') as img:
            expected_req = ({'path': r'/tile.png'},
                            {'body': img.read(), 'headers': {'content-type': 'image/png'}})
            with mock_httpd(('localhost', 42423), [expected_req]):
                resp = self.app.get('/tms/1.0.0/tiles/0/0/0.png')
                eq_(resp.content_type, 'image/png')
                is_png(resp.body)

        assert not os.path.exists(test_config['cache_dir'])
        
        with tmp_image((256, 256), format='png') as img:
            expected_req = ({'path': r'/tile.png'},
                            {'body': img.read(), 'headers': {'content-type': 'image/png'}})
            with mock_httpd(('localhost', 42423), [expected_req]):
                resp = self.app.get('/tms/1.0.0/tiles/0/0/0.png')
                eq_(resp.content_type, 'image/png')
                is_png(resp.body)
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:18,代码来源:test_disable_storage.py


示例11: test_get_tile_webmerc

 def test_get_tile_webmerc(self):
     serv = MockServ(42423, bbox_aware_query_comparator=True)
     serv.expects(
         '/service?layers=foo,bar&width=256&version=1.1.1&bbox=-20037508.3428,0.0,0.0,20037508.3428&service=WMS&format=image%2Fpng&styles=&srs=EPSG%3A3857&request=GetMap&height=256').returns(TEST_TILE)
     with serv:
         resp = self.app.get(str(self.common_tile_req))
     eq_(resp.content_type, 'image/png')
     data = BytesIO(resp.body)
     assert is_png(data)
开发者ID:tjay,项目名称:mapproxy,代码行数:9,代码来源:test_multi_cache_layers.py


示例12: test_get_map_uncached

    def test_get_map_uncached(self):
        assert os.path.exists(os.path.join(test_config['base_dir'], 'cache.gpkg')) # already created on startup

        self.common_map_req.params.bbox = '-180,0,0,80'
        serv = MockServ(port=42423)
        serv.expects('/tiles/01/000/000/000/000/000/001.png')
        serv.returns(create_tmp_image((256, 256)))
        with serv:
            resp = self.app.get(self.common_map_req)
            eq_(resp.content_type, 'image/png')
            data = BytesIO(resp.body)
            assert is_png(data)

        # now cached
        resp = self.app.get(self.common_map_req)
        eq_(resp.content_type, 'image/png')
        data = BytesIO(resp.body)
        assert is_png(data)
开发者ID:tjay,项目名称:mapproxy,代码行数:18,代码来源:test_cache_geopackage.py


示例13: test_single_color_tile_store_w_alpha

 def test_single_color_tile_store_w_alpha(self):
     img = Image.new('RGBA', (256, 256), color='#ff0105')
     tile = Tile((0, 0, 4), ImageSource(img, image_opts=ImageOptions(format='image/png')))
     self.cache.link_single_color_images = True
     self.cache.store_tile(tile)
     assert self.cache.is_cached(tile)
     loc = self.cache.tile_location(tile)
     assert os.path.islink(loc)
     assert os.path.realpath(loc).endswith('ff0105ff.png')
     assert is_png(open(loc, 'rb'))
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:10,代码来源:test_cache_tile.py


示例14: test_out_of_extent

 def test_out_of_extent(self):
     resp = self.app.get('http://localhost/service?SERVICE=WMS&REQUEST=GetMap'
         '&LAYERS=direct&STYLES='
         '&WIDTH=100&HEIGHT=100&FORMAT=image/png'
         '&BBOX=-10000,0,0,1000&SRS=EPSG:25832'
         '&VERSION=1.1.0&TRANSPARENT=TRUE')
     # empty/transparent response
     eq_(resp.content_type, 'image/png')
     assert is_png(resp.body)
     assert is_transparent(resp.body)
开发者ID:LKajan,项目名称:mapproxy,代码行数:10,代码来源:test_wms_srs_extent.py


示例15: test_get_map_outside

 def test_get_map_outside(self):
     self.common_map_req.params.bbox = -90, 0, 0, 90
     self.common_map_req.params['bgcolor'] = '0xff0005'
     resp = self.app.get(self.common_map_req)
     eq_(resp.content_type, 'image/png')
     data = StringIO(resp.body)
     assert is_png(data)
     img = Image.open(data)
     eq_(img.mode, 'RGB')
     eq_(img.getcolors(), [(200*200, (255, 0, 5))])
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:10,代码来源:test_coverage.py


示例16: test_get_map_outside_transparent

 def test_get_map_outside_transparent(self):
     self.common_map_req.params.bbox = -90, 0, 0, 90
     self.common_map_req.params.transparent = True
     resp = self.app.get(self.common_map_req)
     eq_(resp.content_type, 'image/png')
     data = StringIO(resp.body)
     assert is_png(data)
     img = Image.open(data)
     eq_(img.mode, 'RGBA')
     eq_(img.getcolors()[0][0], 200*200)
     eq_(img.getcolors()[0][1][3], 0) # transparent
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:11,代码来源:test_coverage.py


示例17: test_out_of_extent_bgcolor

 def test_out_of_extent_bgcolor(self):
     resp = self.app.get('http://localhost/service?SERVICE=WMS&REQUEST=GetMap'
         '&LAYERS=direct&STYLES='
         '&WIDTH=100&HEIGHT=100&FORMAT=image/png'
         '&BBOX=-10000,0,0,1000&SRS=EPSG:25832'
         '&VERSION=1.1.0&TRANSPARENT=FALSE&BGCOLOR=0xff0000')
     # red response
     eq_(resp.content_type, 'image/png')
     assert is_png(resp.body)
     assert_colors_equal(img_from_buf(resp.body).convert('RGBA'),
             [(100 * 100, [255, 0, 0, 255])])
开发者ID:LKajan,项目名称:mapproxy,代码行数:11,代码来源:test_wms_srs_extent.py


示例18: test_get_tile_utm

    def test_get_tile_utm(self):
        serv = MockServ(42423, bbox_aware_query_comparator=True)
        serv.expects(
            '/service?layers=foo,bar&width=256&version=1.1.1&bbox=-46133.17,5675047.40429,580038.965712,6301219.54&service=WMS&format=image%2Fpng&styles=&srs=EPSG%3A25832&request=GetMap&height=256').returns(TEST_TILE)
        self.common_tile_req.params['tilematrixset'] = 'utm32'

        with serv:
            resp = self.app.get(str(self.common_tile_req))
        eq_(resp.content_type, 'image/png')
        data = BytesIO(resp.body)
        assert is_png(data)
开发者ID:tjay,项目名称:mapproxy,代码行数:11,代码来源:test_multi_cache_layers.py


示例19: test_get_tile_with_layer

    def test_get_tile_with_layer(self):
        expected_req = [({'path': '/arcgis/rest/services/ExampleLayer/MapServer/export?f=image&format=png&layers=show:0,1&imageSR=900913&bboxSR=900913&bbox=-20037508.342789244,-20037508.342789244,20037508.342789244,20037508.342789244&size=512,512'},
                 {'body': transp, 'headers': {'content-type': 'image/png'}}),
                ]

        with mock_httpd(('localhost', 42423), expected_req, bbox_aware_query_comparator=True):
            resp = self.app.get('/tms/1.0.0/app2_with_layers_layer/0/0/1.png')
            eq_(resp.content_type, 'image/png')
            eq_(resp.content_length, len(resp.body))
            data = BytesIO(resp.body)
            assert is_png(data)
开发者ID:tjay,项目名称:mapproxy,代码行数:11,代码来源:test_arcgis.py


示例20: test_02_get_legendgraphic_layer_static_url

 def test_02_get_legendgraphic_layer_static_url(self):
     self.common_lg_req_111.params['layer'] = 'wms_layer_static_url'
     with tmp_image((256, 256), format='png') as img:
         img_data = img.read()
         expected_req1 = ({'path': r'/staticlegend_layer.png'},
                          {'body': img_data, 'headers': {'content-type': 'image/png'}})
         with mock_httpd(('localhost', 42423), [expected_req1]):
             resp = self.app.get(self.common_lg_req_111)
             eq_(resp.content_type, 'image/png')
             data = StringIO(resp.body)
             assert is_png(data)
             assert Image.open(data).size == (256,256)
开发者ID:Anderson0026,项目名称:mapproxy,代码行数:12,代码来源:test_legendgraphic.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python image.tmp_image函数代码示例发布时间:2022-05-27
下一篇:
Python image.is_jpeg函数代码示例发布时间: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