Skip to content

Instantly share code, notes, and snippets.

@lazerl0rd
Last active March 5, 2020 18:44
Show Gist options
  • Save lazerl0rd/9506f1c814a953df62d3136a689e4bbd to your computer and use it in GitHub Desktop.
Save lazerl0rd/9506f1c814a953df62d3136a689e4bbd to your computer and use it in GitHub Desktop.
A Shell Script to embed PNGs in a SVG container.
#!/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