Hack Forums
[C#] SVG 2 PNG Converter - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] SVG 2 PNG Converter (/showthread.php?tid=5657884)



SVG 2 PNG Converter - Narwin - Jun 28, 2017

Hi there.

A day I got an (SVG)iconpack I needed them in PNG ImageFormat but I searched a lot on internet to find a something to convert them but I got to ways, one online converters and IE Explorer so that I tried to create a tool to doing such a thing.

As I said it earlier there two are ways maybe more but what if you have a 200 images in SVG format and try to convert , it's really hard to upload them online or opening them in IE then save.

The tool supports multiple number of svg files to convert.

Credits :

SVG Library

Source :

Spoiler (Click to View)


* - CanadianBacon - Jun 28, 2017

Nice thanks for this converter if you have time you should make a few different modules like svg to jpg or png to jpg and that stuff.


* - Narwin - Jun 28, 2017

(Jun 28, 2017 05:18 PM)CanadianBacon Wrote:  Nice thanks for this converter if you have time you should make a few different modules like svg to jpg or png to jpg and that stuff.

it converts SVG to
  • Bmp

  • Gif

  • Jpeg

  • Png

  • Tiff

  • Icon



for the other suggestion I may if I got enough time.


* - Ninja - Jun 28, 2017

I used an app that adds himself to the context menu of Windows Explorer when clicking on SVG files to convert them and even resize them.

http://www.bricelam.net/ImageResizer/


RE: SVG 2 PNG Converter - lovnee - Sep 19, 2018

This an Adobe Illustrator script to convert .AI & .SVG to .PNG  ✌
I used this script to convert 3400 .SVG to .PNG in a single go.
Save it as ExportDocsAsPNG24.jsx & use *.ai or *.svg to specify file type.



Code
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pngExportOpts;
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to PNG', '~' );
if ( sourceFolder != null )

{

files = new Array();
fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', ' ' );
files = sourceFolder.getFiles( fileType );
if ( files.length > 0 )

{
destFolder = Folder.selectDialog( 'Select the folder where you want to save the converted PNG files.', '~' );
for ( i = 0; i < files.length; i++ )
{
sourceDoc = app.open(files[i]);
targetFile = getNewName();
pngExportOpts = getPNGOptions();
sourceDoc.exportFile( targetFile, ExportType.PNG24, pngExportOpts );
sourceDoc.close(SaveOptions.DONOTSAVECHANGES);

}
alert( 'Files are saved as PNG in ' + destFolder );
}

else
{
alert( 'No matching files found' );
}

}

function getNewName()
{
var ext, docName, newName, saveInFile, docName;
docName = sourceDoc.name;
ext = '.png';
newName = "";
for ( var i = 0 ; docName[i] != "." ; i++ )
{
newName += docName[i];
}
newName += ext; // full png name of the file
saveInFile = new File( destFolder + '/' + newName );
return saveInFile;

}

function getPNGOptions()

{
var pngExportOpts = new ExportOptionsPNG24();
pngExportOpts.antiAliasing = true;
pngExportOpts.artBoardClipping = false;
pngExportOpts.saveAsHTML = false;
pngExportOpts.transparency = true;
return pngExportOpts;
}