Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ Note that the second parameter of ``drawToFile`` can be any
`Python file object`_, like a ``BytesIO`` buffer if you don't want the result
to be written on disk for example.

You can convert a svg file to pillow image object as following snippet:

.. code:: python

from svglib.svglib import svg2rlg
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking, but this order would be a more recommended one: stdlib, external, and local packages, not split with empty lines here for brevity:

import io
from PIL import Image
from reportlab.graphics import renderPM
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()

In addition a script named ``svg2pdf`` can be used more easily from
the system command-line. Here is the output from ``svg2pdf -h``::

Expand Down Expand Up @@ -175,7 +191,7 @@ With the ``pip`` command on your system and a working internet
connection you can install the newest version of ``svglib`` with only
one command in a terminal::

$ pip install svglib
$ pip install svglib rlPyCairo reportlab
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reportlab is listed as a dependency in requirements.txt so it should not be needed here.


You can also use ``pip`` to install the very latest version of the
repository from GitHub, but then you won't be able to conveniently
Expand Down
Loading