-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert all files to PNG #12
Comments
I made you a #!/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: It creates a I use |
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() |
@JulioPDX your useful script worked for me with cairosvg instead of pyvips. Thanks for that!
|
@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. |
No description provided.
The text was updated successfully, but these errors were encountered: