Last active
June 1, 2023 17:52
-
-
Save vadimkantorov/ccd451ff0d6f9b188c11822acfdd64a9 to your computer and use it in GitHub Desktop.
Convert an image to Base64 data-uri format using ImageMagick and OpenSSL
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
# Usage: | |
# bash image2urijpeg.sh image.jpg 320x240 > base64.txt # will resize before conversion | |
# bash image2urijpeg.sh image.jpg > base64.txt # will keep original size | |
magick "$1" -resize ${2:--} jpeg:- | openssl enc -base64 -A | sed -e 's/^/data:image\/jpeg;base64,/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment