On the command line, I can do:
convert sourceimg.jpg | base64
and receive a string of output representing the image. However, if I add any transformations to the image, nothing is output:
convert sourceimage.jpg -resize 400x400 output.img | base64
Is there a quick way to get the base64 representation of the result of imagemagick commands?
If you want the output image as a PNG
, use:
convert input.jpg -resize 400x400 PNG:- | base64
If you want the output image as a JPG
, use:
convert input.jpg -resize 400x400 JPG:- | base64
In ImageMagick there is an INLINE: format that will save to base 64. See http://www.imagemagick.org/Usage/files/#inline
So you can also do
variable=$(convert input.jpg -resize 400x400 INLINE:PNG:-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With