
Select both the rectangle and the vector image.None of these answers (and multiple similar/duplicates) seemed to completely answer this and provide an example. Select one of the shape tools in the left bar. This is the easiest method and equivalent to crop in more editors. There are many ways to accomplish this task. Say you only wanted the cow in this image. Cropping a shape in Inkscape.

Crop In Inkscape Code Within The
Change the width and height attributes to the "actual" dimensions you determined in step #1. You'll be changing the code within the svg element tag only. If there are multiple path elements, I've found the last one is often the "containing" element.Now edit the svg code directly in your text / code editor of choice. You'll see the width and height displayed next to the actual svg in your browser. For me, this was easiest to do by using the (Chrome) inspector and hovering over the path element within the inspector.
If you'd like to walk through this exact example, just wrap all of the code below in HTML tags svg code and open in your browser. In simpler (CSS) terms, your left margin and your top margin.This example will make it extremely simple, and will use the svg directly below as reference. These will respectively be changed (from what was likely 0 0) to: half of the difference between the initial width and height and the actual width and height. The 1st and 2nd dimensions are the x and y coordinates for the "origin" of the portion of the svg that is within the viewBox. We'll start with the 3rd and 4th numbers, which will again be your "actual" width and height. No units though, just the numbers (ie.
Width="40" height="40"+ Our initial dimensions were 48 x 48 and our actual dimensions (sans padding) are 40 x 40. Change the svg attributes to reflect this. For this example, the actual dimensions are 40 x 40.
+ If the padding around your svg has different amounts for the top / bottom and right / left, this is not a problem. ViewBox="4 4 40 40"+ Our opening svg tag should now reflect these changes. Change the viewBox attribute accordingly, and add our actual width and height.
If you need further control of aspect ratio you can always use the preserveAspectRatioSpec fragment identifier.In order to find the viewBox for the entire image visit the svg url directly and inspect the page elements to find the viewBox defined on the outermost svg element.Armed with that information you can now tailor your viewbox to your needs.Before attempting to fix with code, you may want to attempt to optimise your SVGs layout. The first 2 parameters are the x and yCoordinates of the top left corner of your viewbox and the second 2 parameters are the width and height of your viewbox.Using this technique your img tags will look something like this: It's important to ensure that the aspect ratio of the viewbox matches the aspect ratio of the img tag, if not your viewbox will not be correctly sized/aligned. Fragment identifiers allow you to define the segment of an SVG that you wish to display in an img tag as well as allowing for control of image transforms and aspect ratio.Adding #svgView(viewBox(0, 0, 32, 32)) to the end of your svg url defines the area in the svg that you want to display. Entirely open to suggestions / edits from anyone more knowledgeable on manipulating scalable vector graphics than IYou can do exactly what you want with fragment identifiers.
What you want to do is ensure your SVG is the same size as the artboard. You should see something similar to this:The white area is your artboard, the circle your SVG. If you have Adobe Illustrator available open your SVG in that.
If the surrounding box doesn't touch the edges of your circle when selected you have a clipping mask which is pushing your image boundaries out.Looking at your image, this could potentially be quite complicated and if you aren't too familiar with vector editing it might be faster and easier to pass it back to a designer. To tell if there is a clipping mask affecting your SVG click your circle. In which case you'll need to remove these masks where possible.
