Comments (4)
I made you a bash
script to automate the task:
#!/bin/bash
if [ -n "${1}" ]
then
if [ ! -d ${1} ]
then
echo "Directory not found."
exit 1
fi
else
echo -e "You must provide the directory containing the Affinity SVGs.\nFor example: ./convertAffinitySvg.sh /home/toto/Downloads/affinity/svg"
exit 1
fi
extention_src="svg"
extention_dst="png"
export_dpi=300
rep_affinity_src="${1}"
rep_affinity_dst="/tmp/affinity/${extention_dst}/"
cd ${rep_affinity_src}
creatRepDst()
{
for rep in $(find . -mindepth 1 -type d); do
mkdir -p ${rep_affinity_dst}/${rep}
done
}
convertImg()
{
for convert in $(find . -mindepth 1 -name "*.${extention_src}"); do
suppr_extension=${convert%.*}
inkscape ${convert} -o ${rep_affinity_dst}/${suppr_extension}.${extention_dst} --export-type=${extention_dst} --export-dpi=${export_dpi}
done
}
creatRepDst
convertImg
You have to use it like this: ./convertAffinitySvg.sh ~/Downloads/affinity/svg
It creates a /tmp/affinity/png/
directory, creates the Affinity SVG tree and converts (by copying) the SVGs to PNG or any other format supported by Inkscape
(svg,png,ps,eps,pdf,emf,wmf,xaml) by changing the value of the variable extension_dst
(the created directory adapts to the extension).
I use Inkscape
for conversion. There may be more optimized. I'll see...
If you have any questions, don't hesitate ;)
from affinity.
FYI, a bit late to the party. Also made a fork and python script for converting to PNG and size for the popular EVE-NG network simulation tool. https://github.com/JulioPDX/affinity/blob/master/convert.py
#!/usr/bin/env python
"""
Script used to convert a bunch of SVG files to PNG
"""
from os import walk, mkdir
import pyvips
# sudo apt-get install libvips
# pip install pyvips
PATH = "svg/"
def main():
"""
All the action
"""
for (root, dirs, files) in walk(PATH):
for f in files:
if ".svg" in f:
try:
mkdir(path=f"{root}/png/")
except OSError as error:
pass
convert_file = pyvips.Image.thumbnail(f"{root}/{f}", 52, height=52)
convert_file.write_to_file(f"{root}/png/{f.replace('svg', 'png')}")
if __name__ == "__main__":
main()
from affinity.
@JulioPDX your useful script worked for me with cairosvg instead of pyvips. Thanks for that!
cairosvg.svg2png(url=f"{root}/{f}", write_to=f"{root}/png/{f.replace('svg', 'png')}")
from affinity.
@dalcacer Wow! I'm very happy I could be of help! I think I initially attempted with cairo but had some issue. Probably user error.
from affinity.
Related Issues (20)
- Add GNS3 versions of the symbols to this repository? HOT 5
- Incorrect gray color on square symbols
- Create SVG files in more colors
- Add an icon that represents a laptop HOT 1
- Create new icons with clean code HOT 2
- Please add an Optical/Laser icon HOT 2
- symbols as Visio stencil? HOT 1
- Lucid Chart SVG import error HOT 3
- Visio stencils in other colors than blue? HOT 1
- Request for VPN icon
- Generic sensor symbol (IoT/edge device) HOT 1
- Symbol: API HOT 3
- mine truck icon HOT 1
- Symbol: Component HOT 2
- Symbol: Proxy
- implementation issues HOT 1
- Visio 2019 corruption issue HOT 1
- Phone Stencil? HOT 3
- Reference page with all symbols HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from affinity.