deeplook / svglib

Read SVG files and convert them to other formats.
GNU Lesser General Public License v3.0
307 stars 79 forks source link

Add more example and pip install commands to README.md #391

Open dinhanhx opened 7 months ago

dinhanhx commented 7 months ago

For example section, the following code can be added to demonstrate how to convert a svg file to a Pillow Image object

Example svg file: https://upload.wikimedia.org/wikipedia/commons/4/4f/SVG_Logo.svg

from svglib.svglib import svg2rlg
from reportlab.graphics import renderPM
from PIL import Image
import io

drawing = svg2rlg("SVG_Logo.svg")
place_holder = io.BytesIO()
renderPM.drawToFile(drawing, place_holder, fmt="PNG")

image = Image.open(place_holder)
image.show()

For pip install section, I believe it would be better if this was added

pip install svglib rlPyCairo reportlab

So other people can have quick installation without fixing missing dependencies.

github-actions[bot] commented 7 months ago

Thank you for raising your first issue! Your help to improve svglib is much appreciated!

claudep commented 7 months ago

Thanks for this suggestion, would you like to create a pull request with this snippet?

dinhanhx commented 7 months ago

I believe it would be better if you do that because you might want to edit the suggested examples.

deeplook commented 7 months ago

We can easily adjust it after you add a contribution to this package and your own list. ;-)