Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch export png to svg
#1
Is it possible to batch export png files (with transparent background) to pixel perfect svg files (a whole folder)? How to do this in gimp?


Example files: the exported png files from this

https://www.gimp-forum.net/Thread-cut-sq...from-iamge

PS: I don't know if gimp supports SVG. If not, what open source/free program would you recommend to do this on windows?
Reply
#2
(02-23-2024, 07:25 PM)gimpygirl Wrote: Is it possible to batch export png files (with transparent background) to pixel perfect svg files (a whole folder)? How to do this in gimp?

No, Gimp is very much a bitmap editor and does not export to SVG (vector formats)

Inkscape is the vector application that can take a png and trace to a svg.  Batch tracing is something else and you better ask on the Inkscspe forum. https://inkscape.org/forums/

Probably a better bet is commsnd line Autotrace for Windows see; https://github.com/autotrace/autotrace/releases

I use linux (not Windows) and a conversion png -> svg

   

You would need to bundle that command up into a batch file

It looks like ImageMagick might support AutoTrace as a delegate and make batch operations easier. 

Ask here: https://github.com/ImageMagick/ImageMagick/discussions Nice people, always helpful.
Reply
#3
This autotrace is perfect. Thanks so much, I'm very close to what I want to do now!

But I don't know how to make batch file  Sad 
Do you (or anybody) have the knowledge to make a Windows batch file that loops through a folder and does the command for each png in the folder?
Reply
#4
No replies from Windows users ?

However, to get you started a Windows batch file (attached, unzip it)

One question. Are all the images such as test.xcf the same size ? Otherwise you will need to adjust the batch file to suit. The same applies to file names.

You do need the test.xcf exported to png format.

You need Imagemagick installed. https://imagemagick.org/script/download.php
This one: https://imagemagick.org/archive/binaries...64-dll.exe

and

The latest Autotrace for Windows is broken. Get the 0.4 version from https://github.com/autotrace/autotrace/releases
This one: https://github.com/autotrace/autotrace/r...-setup.exe

Problems uploading a small video to google. They seem to changing everything again Wink

A four minute demo with some information. https://youtu.be/Fn2qne88n5w





Edit: Correction. I forgot to remove a 'rem' which commented out a line in the bat file. Make the bat file stop with an error.
Fixed and a new tiles-crop.zip


Attached Files
.zip   tiles-crop.zip (Size: 367 bytes / Downloads: 54)
Reply
#5
Hi

Thanks SO MUCH!!! Another great video!
I can never find this out myself...

To answer your question: yes, the size is always the same but sometimes the squares can have other dimensions. (For now this is not the case)
So then I have to adjust the numbers I think?

Is Imagemagick meant to be used by batch file or is this not necessarely how it should be used?


The images come from the MAME emulator: inside a game you press F4 and then 'enter' to view the game fonts. I then just take a screenshot of this. That's why the resolution of the image is always the same.
My goal is to create a SVG font with colors from the exported images (for personal use). Not sure what free or commercial software I need for this (behond the scope of this forum I think... But feel free to send me a PM if you want to help)

Some links

https://www.mamedev.org/

https://www.colorfonts.wtf/

Does anybody know if gimp itself supports these kind of svg color fonts to be used for text?

Will this batch file still work if I first remove,all the square's background (so it's transparent) in gimp?
If you read a bit higher post of me, the method with gmic fails then.
Here: https://www.gimp-forum.net/Thread-cut-sq...from-iamge
Reply
#6
(02-25-2024, 05:31 AM)gimpygirl Wrote: To answer your question: yes, the size is always the same but sometimes the squares can have other dimensions. (For now this is not the case)
So then I have to adjust the numbers I think?

Yes, you will probably need to change some of the parameters if the tile size changes / case-by-case basis. Sadly if there are mixed sizes, ImageMagick (IM) crop is not the tool. You can set up guides individually and go the guillotine / export layers route.

Quote:Is Imagemagick meant to be used by batch file or is this not necessarely how it should be used?

IM is command line and can be used for individual procedures in a terminal. Much easier in linux than Windows.

Quote:Does anybody know if gimp itself supports these kind of svg color fonts to be used for text?
Will this batch file still work if I first remove,all the square's background (so it's transparent) in gimp?

No SVG fonts in Gimp. You need to look at Inkscape, ask on their forum: https://inkscape.org/forums/  There are video tutorials on making SVG fonts.

That batch file, note it was broken (my fault) but fixed now, produces a solid background. There is provision in Autotrace for removing the background colour but because of the nature of your images you will need to do a bit of manual editing first to replace the background with a suitable colour. I use magenta hex FF00FF because you do not often find it in these graphics.

   

(1)Select the dark grid (2) Fill with Black and turn selection off (3) Use Colors -> Map -> Color Exchange to swap Black to Magenta.

Snags, sometimes less is not better than more, only really 4 colours red, white, black, and some shadow. Pure magenta FF00FF in Autotrace will remove a main color. Needs to be off a little in Autotrace FF01FF.  Example screenshots:

   
(4) Using -background-color FF00FF (5) using -background-color FF01FF (do expect this to work on all images, some experimenting required)
This gives a modified Windows batch file (attached, unzip it)
Put it in a folder with the magenta background image and run in a terminal.
Attached a zip of the results I got in Windows 10. I have to say, everything is much easier in linux. Edit: Some of the svg are not 100%, you would have to edit one or two in Inkscape or take a bit more time with the initial magenta background "test.png"


Attached Files
.zip   test-svg.zip (Size: 35.83 KB / Downloads: 26)
.zip   tiles-bg.zip (Size: 388 bytes / Downloads: 19)
Reply
#7
Thanks for all the replies!

Maybe it's easier to use your first method using the guides since with that method you KNOW the result is correct?
If I use this method now, I need to check everything and at the end maybe it takes much more time then the first method proposed by you (+ the fact that some images will have another square grid and I need to modify the batch file too)?

What do you think and recommend?
Reply
#8
(02-25-2024, 06:30 PM)gimpygirl Wrote: Thanks for all the replies!

Maybe it's easier to use your first method using the guides since with that method you KNOW the result is correct?
If I use this method now, I need to check everything and at the end maybe it takes much more time then the first method proposed by you (+ the fact that some images will have another square grid and I need to modify the batch file too)?

What do you think and recommend?

The great thing with Gimp, there is usually more than one way to get a result. Some ways are easier than others.

Just keep trying.
Reply
#9
Hi

Using the guides and then the plugins, I have the result I want. I decided to keep using this way.

I generated my font, see example below Heart Heart Heart


Attached Files Thumbnail(s)
   
Reply


Forum Jump: