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, helmut, xnview

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

How do I open SVG files and convert to PNG

Post by marjohn »

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: 6339
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 »

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 »

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: 6339
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 »

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 »

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 337 times
User avatar
XnTriq
Moderator & Librarian
Posts: 6339
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 »

Converting weather2.svg with XnView Classic + RSVG-Convert results in a 32-bit PNG with a transparent background:
XnView Classic v2.37 + RSVG v2.40.16
XnView Classic v2.37 + RSVG v2.40.16
p135288_1.png (39.37 KiB) Viewed 11931 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:
XnView Classic v2.37 + RSVG v2.40.16 + 24-bit color depth
XnView Classic v2.37 + RSVG v2.40.16 + 24-bit color depth
p135288_2.png (34.46 KiB) Viewed 11931 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:
XnView MP v0.83
XnView MP v0.83
p135288_3.png (43.38 KiB) Viewed 11929 times
Last but not least, there's the CadSoftTools plug-in:
XnView Classic v2.37 + CadSoftTools v11.1
XnView Classic v2.37 + CadSoftTools v11.1
p135288_4.png (12.66 KiB) Viewed 11913 times
User avatar
XnTriq
Moderator & Librarian
Posts: 6339
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 »

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:
XnView MP v0.83 + Source Sans Pro
XnView MP v0.83 + Source Sans Pro
p135293.png (40.81 KiB) Viewed 11909 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 »

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: 6339
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 »

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 »

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: 6339
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 »

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-)
miksmith
Posts: 18
Joined: Wed Jun 17, 2009 3:04 pm

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

Post by miksmith »

How do you change the import resolution of the SVG?

Thanks!
User avatar
XnTriq
Moderator & Librarian
Posts: 6339
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 »

miksmith wrote: Mon Dec 16, 2019 3:18 pmHow do you change the import resolution of the SVG?
Please refer to my post on how to install the CADSoftTools Manager (screenshot).
miksmith
Posts: 18
Joined: Wed Jun 17, 2009 3:04 pm

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

Post by miksmith »

Thanks for pointing me to the CS Manager - Ive installed this into the plugins folder and can run it and set the import size, however no matter what I do Xnview always produces a 466x466 size image. What am I doing wrong?

thanks!
User avatar
XnTriq
Moderator & Librarian
Posts: 6339
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 »

miksmith wrote: Mon Dec 16, 2019 10:19 pmIve installed this into the plugins folder and can run it and set the import size, however no matter what I do Xnview always produces a 466x466 size image. What am I doing wrong?
Are you sure CADImage.dll is in the Plugins subdirectory of your XnView installation?

http://www.dannyromano.com/wp-content/uploads/TechIcon_XnViewMP.svg
http://www.dannyromano.com/wp-content/uploads/TechIcon_XnViewMP.svg

The value for Maximum Width or Height of Drawing is saved in HKEY_CURRENT_USER\Software\SoftGold\CS_Plugins:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\SoftGold\CS_Plugins]
"Size"="960"
Post Reply