Base64 inline data images

Converting base64 images

convert inline:imagefile.b64 -flip inline:converted_imagefile.b64
  • NOTE data:image/png;base64, must precede the image data in the base64 file
  • convert ImageMagick command, see convert man page
  • inline: identifies it as a Pseudo-image format. See the ImageMagick Site for further details.
  • imagefile.b64 The inline base64 image file
  • -flip Optional: This is only one of many options available to convert to modify the image during conversion. -flip will flip image vertically. More options here at the convert man page
  • inline:converted_imagefile.b64 The output inline base64 pseudo format image file named converted_imagefile.b64

Convert image to base64 inline data

openssl enc -base64 -A -in image.png > image.b64
  • enc encode
  • -base64 or -a Base64 encode/decode, depending on encryption flag
  • -A Used with -[base64 a] to specify base64 buffer as a single line
  • -in image.png Input file, in this case image.png
  • > imagefile.b64 overwrite or clobber file, imagefile.b64
  • NOTE data:image/png;base64, is not generated in the file. Depending on how you intend to use the image file, you can optionally add data:image/png;base64,to the beginning of the file.

Convert base64 inline data to Image

convert inline:image.b64 image.png

or, include an option to the convert process

convert inline:image.b64 -flop image.png
  • NOTE data:image/png;base64, must precede the image data in the base64 file
  • convert ImageMagick command
  • inline: identifies it as a Pseudo-image format. See the ImageMagick Site for further details.
  • imagefile.b64 The inline base64 image file
  • -flop Optional: This is only one of many options available to convert to modify the image during conversion. -flop will flop image horizontally. More options here at the convert man page
  • image.png The output image file

Sources:

Ununtu Man Page: ImageMagick
Ubuntu Man Page: convert
StackOverflow: How do I convert a base64 image?
ImageMagick - Formats