简体   繁体   中英

How to crop svg?

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?

Try

convert -crop 100x100+200+150 -scale 1000x750 current-temps.svg

Requires imagemagick to be installed but it's in most distributions' repositories.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM