deeplook / svglib

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

svglib doesn't remove temporary files properly? #393

Closed wgundamj44 closed 7 months ago

wgundamj44 commented 7 months ago

When using svglib on svgs that have images, we found the disk size keeps growing up. The culprit is the temporary files created by this method xlink_href_target.

This line https://github.com/deeplook/svglib/blob/main/svglib/svglib.py#L701 mentioned the temporary files needs to be removed later, but I didn't find the place where they got removed.

Did I miss something or the removal is really missing?

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

It's totally possible the file is never removed. Any implementation suggestion is welcome.

wgundamj44 commented 7 months ago

I think instead of creating a temporary file here https://github.com/deeplook/svglib/blob/main/svglib/svglib.py#L695, maybe it can create a PIL.Image instead. From what I read, reportlab.graphcis.renderPDF.drawImage can accept PIL.Image in new versions.

claudep commented 7 months ago

Any pull request is welcome!

claudep commented 7 months ago

Fixed by 484d3660a34cfedb24431aed8ecbb61a30afb193