Created
February 12, 2019 13:05
-
-
Save dpineiden/d427d74fd6c2b827e9a7c42b8dc56a28 to your computer and use it in GitHub Desktop.
Inkscape fit to draw all images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# inkscape-center <file-or-directory>... | |
# https://graphicdesign.stackexchange.com/questions/22326/how-to-fit-svg-drawings-to-their-canvas-on-the-command-line | |
_analyse() { | |
if [ -d "${1}" ] ; then | |
_centerAll "${1}" ; | |
else | |
_center "${1}" ; | |
fi | |
} | |
_centerAll() { | |
cd "${1}" ; | |
for img in $(ls "*.svg") ; do | |
_filterSyms "${img}" ; | |
done | |
} | |
_filterSyms() { | |
if [[ $(readlink "${1}") == "" ]] ; then | |
_center "${1}" | |
fi | |
} | |
_center() { | |
inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit "${1}" | |
} | |
for arg ; do | |
_analyse "${arg}" ; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment