
Automating app assets with Inkscape - chris84948
https://insertbreakpoint.wordpress.com/2017/05/08/automating-app-assets-with-inkscape/
======
tfeldmann
This is the reason there should be SVG support in every UI framework by now.

~~~
stcredzero
If the UIs are moving to (or already at) the point where the GPU is doing the
work, there is no reason why a subsets of SVGs couldn't be stored as a bunch
of triangles. This would impose a practical scaling limit, but it should cover
the use cases of logos and icons.

~~~
contingencies
_there is no reason why a subsets of SVGs couldn 't be stored as a bunch of
triangles_

See
[https://github.com/fogleman/primitive](https://github.com/fogleman/primitive)
for working SVG-as-triangles generation from bitmaps (or higher
resolution/complexity SVG input).

------
fenomas
> It takes about 30 second to build all those PNGs

Wow! I run a similar automated set up (for a game), with the flow being:
Photoshop layer gets edited -> PNG gets exported -> PNG gets post-processed in
Node -> all PNGs get stitched into a texture map, and even with ~100 images it
runs in a few hundred milliseconds.

Unless InkScape does special SVG stuff I don't know about, I suspect that
using something like ImageMagick, or even some random svg2png.js/py script,
would make this instant - and thus something you can just add to your build
process, rather than worrying about triggering it only when the source files
have changed.

~~~
HelloNurse
The script in the article creates an Inkscape process for each exported file,
I'm surprised it's so fast. I'd look into Python scripting to do the export
from a running instance of Inkscape at the press of a button.

~~~
fenomas
That's one approach, but for something that amounts to a build step the ideal
case is not to have to press a button. For one thing, in a case like this the
source images are probably in a repository and the converted images aren't, so
you can wind up needing to open Inkscape and run the script to keep them in
sync.

------
Boothroid
Nice, I like automation and Inkscape. Always nice to see free software
solutions.

Suggestions - perhaps you could script with another language rather than using
a .bat? For example you could use Python to create the commands. With that you
might also be able some simple looping instead of successive commands, which
would make future changes easier (not that you can't do this with a batch file
also, but personally every time I've tried to do anything similar with batch
files I've ended up losing the will to live..).

~~~
chris84948
Yeah, I'll admit that batch files aren't exactly ideal. As a c# developer
though, I don't ever use Python, so that doesn't come over as easier for me. I
think I moved all the important parts into VARs, so you shouldn't have to
change too much in the script.

If there was an easy cross-platform scripting language that was installed by
default, now we'd be talking.

~~~
darklajid
If you're a C# guy: There's the csharp interpreter (run .cs files) or,
potentially even better, there're F# scripts.

Or, you know, write Powershell (depending on what platforms you need to
support ofc).

~~~
chris84948
Sure, but what exactly do they get me that a batch script doesn't? Not trying
to be difficult, but if the batch script can do it, why would I wade into
Powershell? I definitely think Powershell has it's place, but in this case, I
don't see it.

I definitely don't see using cs files or f# scripts as an easier way of doing
this.

~~~
darklajid
Honestly? If you're good with the current approach, why change it.

That said, there's a LOT of repetition in there and while you probably _can_
improve that in this solution, a 'proper' language might be more readable.
Again, if you're a C# developer, C#/F# (or even Powershell) scripts are
probably ~closer to home~.

That whole script is basically - if I understand it correctly - two unrolled
loops. Instead of two loops (logo dimensions, scale) you're duplicating a
loooot of lines.

If this is no problem: Cool. Then again, maybe you want to improve this
approach in the future?

~~~
chris84948
Maybe { crosses fingers tight } Microsoft could package all this up and do it
for me. I'd love to just supply an SVG file. Although, since I spend time at
work dealing with DXF files supplied by customers, I understand the problem.

------
afro88
We do this kinda thing with Sketch and iOS for all assets (including app
icons). We also do font styling, colors, gradients etc from Sketch to a
styling plist. Kinda annoying to set up, but it's a godsend for styling
updates and whitelabeling.

------
epx
I have been doing this for some time as well, my motivation was ignorance
about Photoshop:
[https://epxx.co/logbook/entries/svg.html](https://epxx.co/logbook/entries/svg.html)

