I have an super large svg background and some elements are rendered on top of the background. I then want to crop the svg such that it fits the elements in the foreground and the background is cropped. Is this possible? I am using svg.js but I could not find a build in function for that. Is it even possible to crop an SVG?
Asked
Active
Viewed 136 times
-4
-
2by adjusting the `viewbox` attribute: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox – Steve Nov 22 '22 at 16:05
-
Did you search beforehand? – Ergis Nov 22 '22 at 16:05
-
@Ergis yes i did – J. Doe Nov 23 '22 at 09:24
2 Answers
1
Try
convert -crop 100x100+200+150 -scale 1000x750 current-temps.svg
Requires imagemagick
to be installed but it's in most distributions' repositories.

Jan Gronemann
- 11
- 1
0
I managed to solve this issue by the viewbox attribute as mentioned by a comment. Google did not give me any results for cropping svg or the other terminology I used before posting this question. If you have the same issue, know that viewbox can "crop" the svg. The elements are still their full size but the "zoom" and "pan" of what you can see is adjusted.

J. Doe
- 335
- 1
- 2
- 11