Search code examples
pythondrawingreportlabpycairowand

Good python module to draw on images


I'm working on a Python project and I'm looking for a nice module to do the following :

  • Draw some bezier curves, on an existing JPEG image, from a given list of points.
  • Then use this image to present it in a PDF.

I have to be able to draw shapes, fill them, and set the opacity of the fill color. I also have to be able to draw images (from existing files) inside the JPEG.

A module that allows me to use drawing paths would be great.

I started using Wand, but I'm not satisfied with the results (quality loss on the areas of the image containing the drawn curves, and filling a path doesn't work as I expected (It draws horizontal lines but doesn't entirely fill the shape), or maybe I didn't use it correctly ?).

I think I'm going to use ReportLab for the PDF part. ReportLab can be used to draw bezier curves, but I would prefer generating the images with the curves before including them inside the PDF.

There are a lot of modules for drawing using Python out there, but it's not easy to determine which module is the best for what I want.

I just started looking into pyCairo, but if you know of any other module that can achieve what I want, please feel free to share.


Solution

  • Pygame has some decent drawing capabilities; I'd suggest looking at that and playing with the pygame.draw module.

    PyCairo is more featureful however, and seems to be the more popular choice. Python Imaging Library (PIL) also might be worth looking into.