Page 1 of 1
SVG page boundaries
Posted: 2015-03-04T09:21:49-07:00
by powerofvoid
I made an SVG image in Inkscape, and it has some objects outside the page boundaries, and I want to convert it to PNG.
I
don't want the stuff outside the page boundaries to be in the resulting PNG. How do I do this?
I tried this, but it included the stuff outside the page boundaries:
Code: Select all
$ convert --version
Version: ImageMagick 6.8.9-8 Q16 x86_64 2014-10-09 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib fontconfig freetype jng jpeg lcms lqr lzma openexr pangocairo png tiff x xml zlib
Re: SVG page boundaries
Posted: 2015-03-04T09:57:51-07:00
by snibgo
I don't want the stuff outside the page boundaries to be in the resulting PNG. How do I do this?
You normally won't get stuff outside the page (or "viewport") boundary.
What version of IM are you using? [EDIT: just seen: 6.8.9-8. An upgrade might help.] What is rendering the SVG? (Inkscape, I hope.)
Most importantly, what is in your SVG? Paste it here, between [ code ] and [ /code ] .
Re: SVG page boundaries
Posted: 2015-03-04T10:56:50-07:00
by powerofvoid
- How do I tell what imagemagick is using to render?
- I made the SVG in Inkscape
- This isn't the image I was using, but it has the same problem for me: ("imagemagick file.svg file.png" produces a 65x18 PNG that contains both the red and green circles, instead of a 60x60 png containing only the green circle with some empty space around it)
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<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:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="60"
height="60"
id="svg3876"
version="1.1"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="New document 1">
<defs
id="defs3878" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.2591067"
inkscape:cx="67.917375"
inkscape:cy="32"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:window-width="613"
inkscape:window-height="699"
inkscape:window-x="606"
inkscape:window-y="251"
inkscape:window-maximized="0">
<inkscape:grid
type="xygrid"
id="grid3884"
empspacing="5"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<metadata
id="metadata3881">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-992.36218)">
<path
sodipodi:type="arc"
style="color:#000000;fill:#00ff00;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="path3886"
sodipodi:cx="30"
sodipodi:cy="30"
sodipodi:rx="10"
sodipodi:ry="10"
d="m 40,30 a 10,10 0 1 1 -20,0 10,10 0 1 1 20,0 z"
transform="translate(0,992.36218)" />
<path
sodipodi:type="arc"
style="color:#000000;fill:#ff0000;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="path3888"
sodipodi:cx="90"
sodipodi:cy="30"
sodipodi:rx="10"
sodipodi:ry="10"
d="m 100,30 a 10,10 0 1 1 -20,0 10,10 0 1 1 20,0 z"
transform="translate(0,992.36218)" />
</g>
</svg>
Re: SVG page boundaries
Posted: 2015-03-04T11:13:57-07:00
by snibgo
When Inkscape is your renderer, the command ...
... should say something like ...
Code: Select all
"inkscape" "C:/Users/Alan/AppData/Local/Temp/magick-1904JlPas75xflNB" --export-p
ng="C:/Users/Alan/AppData/Local/Temp/magick-1904CakC_EfLzr7Z" --export-dpi="90,9
0" --export-background="rgb(100%,100%,100%)" --export-background-opacity="1" > "
C:/Users/Alan/AppData/Local/Temp/magick-1904QGyhjzkpc4k9" 2>&1
svgPage.svg SVG 60x60 60x60+0+0 16-bit sRGB 2.96KB 0.016u 0:00.718
svgPage.svg=>s.png SVG 60x60 60x60+0+0 16-bit sRGB 69c 1.14KB 0.000u 0:00.000
... with no errors.
For your SVG, I get 60x60 pixels, green circle on white background, no red circle.
This is with IM v6.9.0-0 and Inkscape v0.91.
I suggest you upgrade IM, or Inkscape, or both.
Re: SVG page boundaries
Posted: 2015-03-04T11:18:05-07:00
by powerofvoid
For me, it doesn't say anything.
I assume that means it isn't using Inkscape?
EDIT:
Code: Select all
$ inkscape --version
Inkscape 0.48.3.1 r9886 (Jan 29 2013)
EDIT 2: Just updated Inkscape:
Code: Select all
$ inkscape --version
Inkscape 0.91 r (Jan 30 2015)
This doesn't seem to have solved the problem.
EDIT 3:
Code: Select all
$ convert SVG-canvas-test.svg -verbose SVG-canvas-test.png
SVG-canvas-test.svg=>SVG-canvas-test.png PNG 65x18 65x18+0+0 8-bit sRGB 66c 3.23KB 0.000u 0:00.009
EDIT 4:
Code: Select all
$ convert -list format | grep SVG
MSVG rw+ ImageMagick's own SVG internal renderer
SVG rw+ Scalable Vector Graphics (XML 2.7.8)
SVGZ rw+ Compressed Scalable Vector Graphics (XML 2.7.8)
EDIT 5: Okay, this is weird:
Code: Select all
$ convert -list delegate | grep svg
cdr => "uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o"
cgm => "uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o"
dot => "dot" -Tsvg "%i" -o "%o"
dxf => "uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o"
fig => "uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o"
svg => "rsvg-convert" -o "%o" "%i"
This works as expected, producing the 60x60 with a green dot:
Code: Select all
rsvg-convert -o SVG-canvas-test.png SVG-canvas-test.svg
This still doesn't work right, producing both dots:
Code: Select all
$ convert SVG-canvas-test.svg -verbose SVG-canvas-test.png
SVG-canvas-test.svg=>SVG-canvas-test.png PNG 65x18 65x18+0+0 8-bit sRGB 66c 3.23KB 0.000u 0:00.000
Re: SVG page boundaries
Posted: 2015-03-04T12:03:52-07:00
by snibgo
powerofvoid wrote:$ convert SVG-canvas-test.svg -verbose SVG-canvas-test.png
You need "-verbose"
before reading the SVG. If you don't turn it on until after you read it, you get no information about how it has read it.
Re: SVG page boundaries
Posted: 2015-03-04T12:26:24-07:00
by powerofvoid
Code: Select all
$ convert -verbose SVG-canvas-test.svg SVG-canvas-test.png
"inkscape" "SVG-canvas-test.svg" --export-eps="/tmp/magick-7690KEgYgCpFp2e9" --export-dpi="90,90" --export-background="rgb(100%,100%,100%)" --export-background-opacity="1" > "/tmp/magick-7690qEEi2fs9PDyE" 2>&1
"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g65x18 "-sOutputFile=/tmp/magick-76903g_7pFgi78Vd%d" "-f/tmp/magick-76908A1-FefEdCtH" "-f/tmp/magick-7690nikVhs0oo60a"
/tmp/magick-76903g_7pFgi78Vd1 PNG 65x18 65x18+0+0 8-bit sRGB 3.11KB 0.000u 0:00.000
/tmp/magick-7690KEgYgCpFp2e9 PNG 65x18 65x18+0+0 16-bit sRGB 3.11KB 0.000u 0:00.000
SVG-canvas-test.svg=>/tmp/magick-7690KEgYgCpFp2e9 PNG 65x18 65x18+0+0 16-bit sRGB 3.11KB 0.000u 0:00.000
SVG-canvas-test.svg=>SVG-canvas-test.png PNG 65x18 65x18+0+0 8-bit sRGB 66c 3.23KB 0.000u 0:00.009
Apparently it is using inkscape.
Re: SVG page boundaries
Posted: 2015-03-04T12:30:40-07:00
by snibgo
That's better. We see IM is telling Inkscape to export to EPS, so IM then calls Ghostscript. This crazy behaviour was corrected (I remember reporting it) before v6.9.0-0. I suggest you upgrade IM.
Re: SVG page boundaries
Posted: 2015-03-04T20:09:25-07:00
by powerofvoid
Upgrading imagemagick seems to have solved that problem.
EDIT: How do I mark this solved?