本文整理汇总了Python中mapproxy.test.image.is_png函数的典型用法代码示例。如果您正苦于以下问题:Python is_png函数的具体用法?Python is_png怎么用?Python is_png使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_png函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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())
示例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)))
示例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)
示例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))])
示例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))])
示例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)
示例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))])
示例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)
示例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)
示例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)
示例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'))
示例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)
示例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))])