How do I open SVG files and convert to PNG

Ask for help and post your question on how to use XnView Classic.

Moderators: XnTriq, xnview

Post Reply
marjohn
Posts: 5
Joined: Sun Oct 23, 2016 5:37 am

How do I open SVG files and convert to PNG

Post by marjohn » Sun Oct 23, 2016 6:10 am

Could someone please provide me with simple instructions on what I need to do to be able to open SVG files in XnView, then convert them to PNG files.

I've tried various things, like putting rsvg-convert.exe and librsvg-2-2.dll in the Plugins folder, but without any luck.

As you can probably guess, I don't really have any idea what needs to be done, so would appreciate quite detailed (but simple) advice. :)

Cheers,

John

User avatar
XnTriq
Moderator & Librarian
Posts: 5431
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: How do I Open SVG files and convert to PNG

Post by XnTriq » Sun Oct 23, 2016 7:00 am

Welcome to the forum, John (-:

Please download rsvg-convert-dll-2.40.16.7z, extract the archive and move all files (EXE + DLLs) in the root folder to the Plugins sub-directory of your XnView installation. (The contents of rsvg-convert-dll-2.40.16.7z\fonts\ and \rsvg-convert-dll-2.40.16.7z\etc\ are not required for rsvg-convert.exe to run.)
Be sure to activate Display all image file types in Tools » Options... » General » Operations. You should now be able to open SVGs in the viewer as well as batch-convert them to PNG format.

marjohn
Posts: 5
Joined: Sun Oct 23, 2016 5:37 am

Re: How do I Open SVG files and convert to PNG

Post by marjohn » Sun Oct 23, 2016 8:54 am

Hi XnTriq,

Thank you so much for your prompt and precise instructions.

I did exactly as you suggested and voila! - almost all is working as I had hoped.

The fonts of some of the SVG files only appeared as blocks like [], so I copied the folders \etc\fonts to the XnView\Plugins folder and they now appear more or less as they should.

There is, however, still one outstanding problem. When I convert some SVG files to PNG a white background shows as black after the conversion.

Your kind assistance is most sincerely appreciated.

Cheers,

John

User avatar
XnTriq
Moderator & Librarian
Posts: 5431
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: How do I Open SVG files and convert to PNG

Post by XnTriq » Sun Oct 23, 2016 10:45 am

Thanks for reporting back, John! Now I understand what the \etc\fonts\ folder is good for. (I had done my tests with SVGs that didn't have any <text> elements.)

Is it possible to upload a sample file (preferably as ZIP/RAR/7-Zip archive)?

PS: You could also give XnViewMP a try which natively supports the SVG format.
As with XnView “Classic”, you need to activate Show all graphic formats (Tools » Settings... » General » General). In addition to that, svg (and svgz) has to be removed from the exclusion list in Tools » Settings... » File list » Custom filter » Exclude.

marjohn
Posts: 5
Joined: Sun Oct 23, 2016 5:37 am

Re: How do I Open SVG files and convert to PNG

Post by marjohn » Sun Oct 23, 2016 11:18 am

You're welcome.

Not a problem; attached is one example that I've been "playing" with. The fonts are far from perfect in the PNG file after converting from SVG, but I don't have any idea what - if anything - can be done about that.

It will be interesting to see what sort of result you get.

I'd like to give XnViewMP a try at some stage, but it's very late in the day here and I don't have the time to do it right now. Tomorrow, maybe, if time permits.

Once again, thanks for taking the time to help me get this sorted.

Cheers,

John
Attachments
weather2.zip
(2.21 KiB) Downloaded 43 times

User avatar
XnTriq
Moderator & Librarian
Posts: 5431
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: How do I Open SVG files and convert to PNG

Post by XnTriq » Sun Oct 23, 2016 11:50 am

Converting weather2.svg with XnView Classic + RSVG-Convert results in a 32-bit PNG with a transparent background:
p135288_1.png
XnView Classic v2.37 + RSVG v2.40.16
p135288_1.png (39.37 KiB) Viewed 2041 times
The black background you get probably depends on your configuration for viewing transparent PNGs. Please take a look at my “recommendations”.

Converting the 32-bit PNG to true color gets rid of the alpha-channel transparency:
p135288_2.png
XnView Classic v2.37 + RSVG v2.40.16 + 24-bit color depth
p135288_2.png (34.46 KiB) Viewed 2041 times
For comparison, MP's output is also a 32-bit PNG (but with an all white alpha channel), and it seems to use slightly different font settings:
p135288_3.png
XnView MP v0.83
p135288_3.png (43.38 KiB) Viewed 2039 times
Last but not least, there's the CadSoftTools plug-in:
p135288_4.png
XnView Classic v2.37 + CadSoftTools v11.1
p135288_4.png (12.66 KiB) Viewed 2023 times

User avatar
XnTriq
Moderator & Librarian
Posts: 5431
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: How do I Open SVG files and convert to PNG

Post by XnTriq » Sun Oct 23, 2016 5:00 pm

marjohn wrote:The fonts are far from perfect in the PNG file after converting from SVG, but I don't have any idea what - if anything - can be done about that.
The typeface used in weather2.svg

Code: Select all

<text class="text_tick" style="color: rgb(134, 134, 134); font-family: Source Sans Pro; font-size: 14px; font-style: normal; font-weight: 400; opacity: 1;" fill="#868686" transform="rotate(-90 454.69 340)" x="421.6905" y="354"><tspan x="421.9505" y="354" dy="0">21/10</tspan></text>
… is Adobe's Source Sans Pro:
p135293.png
XnView MP v0.83 + Source Sans Pro
p135293.png (40.81 KiB) Viewed 2019 times

marjohn
Posts: 5
Joined: Sun Oct 23, 2016 5:37 am

Re: How do I Open SVG files and convert to PNG

Post by marjohn » Sun Oct 23, 2016 8:59 pm

Thanks, yet again, for all your help. Also for posting the examples, which are most useful.

I've read your 'recommendations' referenced above, and also downloaded the fonts you referred to.

If you haven't run out of patience :) , and have time, could you suggest which fonts I need to install to get the result you did, and where should I install them; for example, install normally into the Windows\Fonts folder, or to a folder under XnView?

Cheers,

John

User avatar
XnTriq
Moderator & Librarian
Posts: 5431
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: How do I Open SVG files and convert to PNG

Post by XnTriq » Sun Oct 23, 2016 9:45 pm

Hi again, John.
marjohn wrote:could you suggest which fonts I need to install to get the result you did, and where should I install them; for example, install normally into the Windows\Fonts folder, or to a folder under XnView?
I installed all fonts in \source-sans-pro-2.020R-ro-1.075R-it\OTF\ via Control Panel to make them available system-wide.
However, this doesn't make a difference when converting with XnView Classic & RSVG :-|
Results for conversion of weather2.svg with XnView MP: “Source Sans Pro” not installed vs. installed

BTW: Do you still get black backgrounds?

marjohn
Posts: 5
Joined: Sun Oct 23, 2016 5:37 am

Re: How do I Open SVG files and convert to PNG

Post by marjohn » Sun Oct 23, 2016 11:14 pm

Thanks for the info regarding installing the fonts. Given the fact that they don't have any effect when using XnView Classic, and only a minimal effect when used with XnView MP, I don't think I'll bother installing them at the moment.

I'm pleased to report that I no longer get the black backgrounds, so overall I'm pretty happy with the results that your advice has allowed me to achieve.

Thank you, yet again, for all your assistance (and patience) :) ; lot's of "hand holding" on your part, but for me it's been well worth the effort.

Cheers,

John

User avatar
XnTriq
Moderator & Librarian
Posts: 5431
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: How do I Open SVG files and convert to PNG

Post by XnTriq » Sun Oct 23, 2016 11:45 pm

marjohn wrote:Given the fact that they don't have any effect when using XnView Classic, and only a minimal effect when used with XnView MP, I don't think I'll bother installing them at the moment.
Plus, we don't even know whether “Source Sans Pro” is the font used in all of your SVGs.
marjohn wrote:Thank you, yet again, for all your assistance (and patience) :) ; lot's of "hand holding" on your part, but for me it's been well worth the effort.
No big deal! You had an interesting question and made me learn a few things about Scalable Vector Graphics 8-)

Post Reply