I am trying to crop an svg file. but it does not crop svg images. I successfully cropped other types of images like png and jpg, Is there any other way of cropping svg file in umbraco ? Please help guys...
An SVG isn't a bitmap file it's a vector. I doesn't really make any sense to me to "crop" a vector, as it's essentially an XML file that defines points. I can't see any logical way you could crop a vector, and it's not something that is supported, I'm afraid.
Svg file with image cropper not working
Hello
I am trying to crop an svg file. but it does not crop svg images. I successfully cropped other types of images like png and jpg, Is there any other way of cropping svg file in umbraco ? Please help guys...
Thanks
Dharmesh
An SVG isn't a bitmap file it's a vector. I doesn't really make any sense to me to "crop" a vector, as it's essentially an XML file that defines points. I can't see any logical way you could crop a vector, and it's not something that is supported, I'm afraid.
Actually, I think it would be very useful if the image cropper would work on vector images as well ... especially for using a custom focal point.
Unfortunately, it doesn't.
Image Cropper is powered by ImageProcessor
It's core supported formats are:
So, you can't use Image Cropper for .svg files and have to find other ways, such as described in How to crop SVG file within HTML/CSS
Hello,
I just wrote following code for getting width and height and applied it to svg:
Then just checked if svg file and gave attributes width and height:
@if (fileExtension == ".svg") { <img src="@urlWithoutCrop" style="width: @(width + "px"); height: @(height + "px");" alt="" class="img-reponsive" /> } else { <img src="@url" alt="" class="img-reponsive" /> }
is working on a reply...