skagedal / svgclip

Clip SVG files to the size of actual drawing. Uses Inkscape to get bounding box.
46 stars 10 forks source link

why use rsvg etc? #3

Closed karelbilek closed 3 years ago

karelbilek commented 4 years ago

Why do you use rsvg/cairo here, when you can just edit the vieport in XML?

It does not reduce the filesize, but is much simpler :)

karelbilek commented 4 years ago

oh, I see that this repo is from 2013. :) but it still works for me!

karelbilek commented 4 years ago

I needed the script for something slightly different (resizing the canvas to square and centering the SVG vertically)

I updated the script to python3 & packaged it to docker, I will send a link there once it's on dockerhub

karelbilek commented 4 years ago

there u go

https://github.com/karel-3d/center-svg-docker

https://hub.docker.com/r/karel3d/center-svg

chrisspen commented 4 years ago

This tool does edit the XML. That's what the rsvg and Inkscape calls do. I don't think you can simply edit the viewport. You need to scan all elements, find their min/max points to calculate the true bounding box, and then update the viewport. For that you need something that can parse SVG's XML and read those points.

skagedal commented 3 years ago

@vmario89 Cool, that looks like just the tool I was looking for back when I did this script. What would be the exact way of invoking vpype to do what svgclip does? As people seem to find their way here, I'd love to update the README with links to perhaps more relevant and updated software.