svglib icon indicating copy to clipboard operation
svglib copied to clipboard

Add more example and pip install commands to README.md

Open dinhanhx opened this issue 2 years ago • 4 comments

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.

dinhanhx avatar Nov 20 '23 03:11 dinhanhx

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

github-actions[bot] avatar Nov 20 '23 03:11 github-actions[bot]

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

claudep avatar Nov 20 '23 07:11 claudep

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

dinhanhx avatar Nov 20 '23 08:11 dinhanhx

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

deeplook avatar Nov 21 '23 10:11 deeplook