本文整理汇总了Python中mapproxy.image.make_transparent函数的典型用法代码示例。如果您正苦于以下问题:Python make_transparent函数的具体用法?Python make_transparent怎么用?Python make_transparent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_transparent函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_paletted
def test_from_paletted(self):
img = self._make_test_image().quantize(256)
img = make_transparent(img, (130, 150, 120), tolerance=5)
assert img.mode == 'RGBA'
assert img.size == (50, 50)
colors = img.getcolors()
eq_(colors, [(1600, (130, 140, 120, 255)), (900, (130, 150, 120, 0))])
示例2: test_with_color_fuzz
def test_with_color_fuzz(self):
img = self._make_test_image()
img = make_transparent(img, (128, 154, 121), tolerance=5)
assert img.mode == 'RGBA'
assert img.size == (50, 50)
colors = img.getcolors()
assert colors == [(1600, (130, 140, 120, 255)), (900, (130, 150, 120, 0))]
示例3: test_no_match
def test_no_match(self):
img = self._make_test_image()
img = make_transparent(img, (130, 160, 120), tolerance=5)
assert img.mode == 'RGBA'
assert img.size == (50, 50)
colors = img.getcolors()
assert colors == [(1600, (130, 140, 120, 255)), (900, (130, 150, 120, 255))]
示例4: test_from_transparent
def test_from_transparent(self):
img = self._make_transp_test_image()
draw = ImageDraw.Draw(img)
draw.rectangle((0, 0, 4, 4), fill=(130, 100, 120, 0))
draw.rectangle((5, 5, 9, 9), fill=(130, 150, 120, 255))
img = make_transparent(img, (130, 150, 120, 120), tolerance=5)
assert img.mode == 'RGBA'
assert img.size == (50, 50)
colors = sorted(img.getcolors(), reverse=True)
eq_(colors, [(1550, (130, 140, 120, 100)), (900, (130, 150, 120, 0)),
(25, (130, 150, 120, 255)), (25, (130, 100, 120, 0))])
示例5: get_map
def get_map(self, query):
if self.res_range and not self.res_range.contains(query.bbox, query.size, query.srs):
raise BlankImage()
if self.coverage and not self.coverage.intersects(query.bbox, query.srs):
raise BlankImage()
try:
resp = self._get_map(query)
if self.transparent_color:
resp = make_transparent(resp, self.transparent_color, self.transparent_color_tolerance)
resp.opacity = self.opacity
return resp
except HTTPClientError, e:
log.warn("could not retrieve WMS map: %s", e)
reraise_exception(SourceError(e.args[0]), sys.exc_info())