本文整理汇总了Python中PythonMagick.Image.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Image.draw方法的具体用法?Python Image.draw怎么用?Python Image.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonMagick.Image
的用法示例。
在下文中一共展示了Image.draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import draw [as 别名]
def handle(self, *args, **options):
routes = glob(options['input']+'/routes-*.json')
routes = sorted(routes, lambda x,y:cmp(stat(path.abspath(x))[8], stat(path.abspath(y))[8]))
segment = 0
img = None
for route in routes:
self.stdout.write('Opening route "%s"\n' % route)
rfile = open(route, 'r')
fc = json.load(rfile)
rfile.close()
if segment == 0:
self.stdout.write('Creating image file.\n')
img = Image('1280x720', 'white')
img.draw(DrawableStrokeColor('black'))
img.draw(DrawableStrokeOpacity(0.01))
img.draw(DrawableStrokeWidth(1.0))
for i,feature in enumerate(fc['features']):
coords = feature['geometry']['coordinates']
coords = map(lambda x:self.proj(x), coords)
for start,end in zip(coords[0:-1],coords[1:]):
img.draw(DrawableLine(start[0], start[1], end[0], end[1]))
segment += 1
if segment == options['number']:
self.stdout.write('Writing image file "%s.png".\n' % route)
img.write(route + '.png')
segment = 0