Scale SVG files to png with specific stroke width and image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
inzaghi89

Scale SVG files to png with specific stroke width and image

Post by inzaghi89 »

Hello,

I want to scale svg files on my pc to png. But there is some kind of problem. I want to set stroke with to 1px, so I use this command:

Code: Select all

mogrify -density 400 -strokewidth 1 -format png mysvgfile*.svg
Svg file names is mysvgfile1.svg, mysvgfile2.svg...

But finally it doesn't work properly. Of course, my svg file has been saved as png. Also there is a problem with width. I want to set 400px of width, but file is... much bigger... same problem is with stroke.

The stroke should have 1px width.

Edit:
It might be in two steps:
1. scaling svg files to another svg with 400px width and 1px stroke.
2. convert svg files to png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Scale SVG files to png with specific stroke width and im

Post by anthony »

The SVG image itself is probably overriding the stroke width setting!

IM has two SVG conversion methods see SVG Input Drivers: RSVG vs MSVG
http://www.imagemagick.org/Usage/draw/#svg_drivers

If you have a RSVG version the converts is external to IM so stroke width is not seen

If it is using MSVG (internal) the stroke width is probably being overridden.


The only solution is to either... modify the SVG file to use strokewidth 1px
OR use a higher resolution and shrink (resize) the image.
However that last will also fail is the stroke is being defined inside the SVG using real-world units rather than pixels
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply