Tuesday, 6 November 2012

PyCairo 02 - Import a png to a svg

This script shows how to embed a png file in a svg with Cairo in PyGtk. The following techniques are adopted:

  1. Cairo for graphics.
  2. Cairo surface pattern.
  3. Set pattern matrix for transformation.
  4. Save the result into a SVG file.

Output


Assume that a file named P6050019a.png is placed in the same folder as this script, a file named d01.svg will be generated by this script on the same folder holding the script, it will look like below.


Source Code


No comments:

Post a Comment