How Do I export an SVG without it getting an <image> element and not a <path> - svg

I keep exporting a PSD element with a clear background as an SVG and I continue to get
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="0.972in" height="0.861in">
<image x="0px" y="0px" width="70px" height="62px" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAA+CAMAAAChgZ0aAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACfFBMVEUnKzT///8nKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQn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jAaA5yTDQUM3bITw1mE8fUA78c3qkGk0dLiV/6ZanB4Ho4AkmM6YxqME0c4w8GxiKGqsEc5ZhjUMavK1RgLLg410Bvfj2uAnMijbHEZtrgwmuUY3CjPZkFp4L4ZD6tmFKFqWeOBqrC+b1aMaYOt79mvm0V8YczIUoxuMm24O5nxI3nrEIKpYMdlBnOYbvOK6JYcbqsqyTMEMx2ZaFKMBewMa1CusN9lJUo6VIx2hN7Dr+InEs+U8bhV00PsWMOBGKOvewjxY8s0S4HY9KKrdNd8YkyGxMcq3aySccwdLWrLxjc9fgycDZtmGfYNbP3lOv0x6Uu3q/yBoZv1npL8cfqumaRE7W0oHDLy1WRRz7jNoh98Z27KN2b4AWk8j5ZRTLGInttfIBisufcZ91KZq4OJDFQSP0yPPRAmU/VEgVHKcaAhczio8duKU/IIwdWgCwGssjDpj11Q6kg29rzGbjBCAPJnstuzgXlqL9on6jSGNp9+LKVSesvg8iI54AnDJiSsGaA5MJ4Rf+x0jFZy2HgtQHrHn4jEiy2Y8xbp6AsBk5fpWPZApdwCM3Pd43gJQZq39Oh44NTMJMOd4la8BoD1o/U/E9V7aFs8tnru4MPGIDFxPm8uu29iIbogdjeucdAxjv8XR/hgPuFqJES/tkDBlrT7QNmiZQYIi8xkEqHuthsaPhK5+BvoAgDZhow/Xc6VRpkvJRnDFib7GfuHz9BMQYgX6D8+g1qMFBEA/ZH3oB7h4G/98P/DXKj2zD/AZ/Mbsp7NMuGAAAAAElFTkSuQmCC" />
</svg>
I would like to export this as a <path> element instead of <image>
this is the PNG of what that SVG is:
I have converted already tried to image trace this on illustrator but the path gets sloppy.
Thanks,
Zlerp

Sorry but Photoshop just doesn't do SVGs like that. SVG is a vector format and the only things in photoshop that are vectors are paths and selections and neither of those have things like line thickness and color so they'd be invisible as an image.
That's what Illustrator is for. Or for a free option, there's InkScape.

Related

How to convert SVGs to GIFs with ImageMagick?

I'd like to convert a SVG that has a reference to a GIF inside into a final GIF.
The SVG shows fine with the GIF in a browser, but converting the file from SVG to GIF results in only converting the first frame of the GIF.
that's my test.svg:
<svg id="TEST" data-name="TEST" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1000" height="1000" viewBox="0 0 2000 2000">
<image width="2000" height="2000" xlink:href="input.gif"/>
</svg>
imagemagick command:
magick convert test.svg output.gif
the result is that only the first frame gets converted into a GIF, not the whole sequence.
Anything I can adjust with the ImageMagick command to make this work?

How to convert SVG to BMP?

This question may have been answered in multiple websites. However, I am having issues getting it to work correctly.
My goal is to convert an SVG file to BMP using command line. Below is the content of a simple SVG file. Note the resolution must be 912x1140px. Thus the resulting BMP file must be 912x1140px as defined in the SVG.
<?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="full" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink" width="912px" height="1140px" preserveAspectRatio="none" viewBox="0,0,9.855,6.1614"><defs />
<rect fill="#FFF" height="100%" width="100%" x="0" y="0" />
<rect x="4" y="2.5" width="1.0" height="1.0" fill="#000" />
</svg>
When I use GIMP using GUI, the resulting BMP file is correct as expected having a size of 912x1140px. The size of the file is ~3.96MB. However I must use the GUI to open my SVG file and manually convert it to BMP. I prefer to use command line because I have a batch of SVG files I want to convert.
When I use ImageMagick to convert, the resulting BMP file gets resized to 855x1069px instead of staying at 912x1140px. The resulting BMP file ~3.48MB: convert myfile.svg myfile.bmp
When I use rsvg-convert, the resulting BMP file is correct 912x1140 but its around 7KB. I am unsure if rsvg-convert even supports BMP format because according to the docs, BMP is not listed as the support format. Thus this leads me to question if the convert BMP file is even correct. rsvg-convert -o myfile.bmp myfile.svg
When I use command line Inkscape, the resulting BMP file is correct resolution of 912x1140, but size is around 6.51KB. I am unsure if this is correct since the BMP file generated using GIMP results in a file size of 3.96MB. Secondly, Inkscape GUI doens't have any options to export to BMP. In addition, it defaults to 32 bits. I want it to be 24 bit depth. inkscape -z myfile.svg -e myfile.bmp

svg + inkscape + unwanted cropping

Given the following test.svg file
<?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="tiny"
height="5cm" version="1.2"
viewBox="-1 -1 2 2"
width="5cm" xmlns="http://www.w3.org/2000/svg"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs />
<rect fill="blue" height="1" width="1" x="0" y="0" />
</svg>
using the command
inkscape -D -z --file=test.svg --export-pdf=text.pdf --export-latex
I get a pdf of 25mm x 25mm. The proportions are correct (I use only half the width and half the height), my question is how do avoid an automatic crop of the picture. I need a PDF of 50mm x 50mm, with only the left upper square filled.
In the inkscape documentation for the option -D (that I use) there is the comment without margins or cropping that is exactly what I need. The result is as described above, cropped.
man inkscape shows the following explanation for -D:
In SVG, PNG, PDF, PS, and EPS export, exported area is the drawing (not page), i.e. the bounding box of all objects of the document...
That is what you describe as cropping. For -C it says:
In SVG, PNG, PDF, PS, and EPS export, exported area is the page. This is the default for SVG, PNG, PDF, and PS, so you don't need to specify this...
So, simply leave off the -D option.

ImageMagick viewbox when converting SVG

I'm trying to convert an SVG file to a PNG using convert, where the input image has SVG artifacts outside the document border - this is a byproduct of sloppy artistry, and is convenient when drawing a pretty picture.
However, when I try to use ImageMagick to convert the SVG file to a rasterized PNG, convert keeps the artifacts outside the border in the result, and recalculates the SVG viewbox. This looks very ugly, and is not what I would like as a result. For instance, I would run the following command:
convert input.svg -depth 200 -units pixelsperinch -border 11inx17in output.png
The SVG document clearly has the border and viewbox defined:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
id="svg2"
viewBox="0 0 990.00002 1530"
height="17in"
width="11in">
...
Yet convert treats the entire SVG document (artifacts and all) as the input image, recalculates the viewbox, and the resulting output is slightly skewed, in addition to the extra artifacts spilling outside the document border.

Expand SVG path to fit container of all dimensions

I'm trying to have a SVG path scale to fit the entire container element, without stretching or being trimmed. The SVG is the one below. As you can see, it's a simple border.
<svg preserveAspectRatio="none" viewBox="0 0 370 80" height="100%" width="100%">
<path vector-effect="non-scaling-stroke" d="M359,70C359,70,300,70,185,70C84,70,9,70,9,70C9,70,9,60,9,40C9,24,9,10,9,10C9,10,84,10,185,10C300,10,359,10,359,10C359,10,359,24,359,40C359,60,359,70,359,70C359,70,359,70,359,70"/>
</svg>
Then I have an element that could have different sizes, because it's responsive and because I use it in various cases where width or height can be different. I can't succeed in having the SVG that expands its path by always staying inside the viewport, but scaling without preserving aspect ratio. It doesn't seem a difficult logical thing to do, but I tried various options without success.
EDIT
I was able to scale this SVG, by setting whatever dimensions I wanted. Why does the first not work, but this works instead?
<svg preserveAspectRatio="none" viewBox="0 0 404 77" height="100%" width="100%">
<path vector-effect="non-scaling-stroke" d="m0,0l404,0l0,77l-404,0l0,-77z"/>
</svg>
The short answer is no. What you want to do (as I understand it) is not possible. In SVG you can scale to fit the container (using constant aspect ratio), or you can stretch (ignoring aspect ratio).
There is no way currently to keep some parts of the SVG static and stretch other parts. Unless, of course, you use Javascript to manipulate the contents of the SVG.
What you may want to do is consider using an SVG as the source image for a CSS border-image (see http://www.w3.org/TR/css3-background/#border-images). Perhaps that is the sort of thing you were after?

Resources