Using Pycairo to generate images dynamically and serve in Django

∥☆過路亽.° 提交于 2019-12-04 21:10:24
def someView(request):
  surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
  context = cairo.Context(surface)
  # Draw something ...

  response = HttpResponse(mimetype="image/png")
  surface.write_to_png(response)
  return response

You can try this: http://www.stuartaxon.com/2010/02/03/using-cairo-to-generate-svg-in-django It's about SVG but I think it will be easy to adapt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!