Last active
March 5, 2020 18:44
-
-
Save lazerl0rd/9506f1c814a953df62d3136a689e4bbd to your computer and use it in GitHub Desktop.
A Shell Script to embed PNGs in a SVG container.
This file contains 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
#!/usr/bin/env bash | |
# A Shell Script to embed PNGs in a SVG container. | |
# Diab Neiroukh - 5/Mar/2020 (Licensed under the GNU GPLv3) | |
imageHeight="$(convert "$1" -print "%h" /dev/null)" | |
imageWidth="$(convert "$1" -print "%w" /dev/null)" | |
echo "<svg width=\"$imageWidth\" height=\"$imageHeight\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" > | |
<image href=\"data:image/png;base64,$(base64 -w0 < "$1")\" width=\"$imageWidth\" height=\"$imageHeight\" ></image> | |
</svg>" > "${1%.png}.svg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment