Go to "Filters" menu -> "Python-Fu". The python console should appear.1. Take an image
img = gimp.image_list()[0] // assuming you'd got just one image opened2. Read all bytes
bytes = open(img.filename, "rb").read()3. Encode bytes with 'base64' algorithm
bytes.encode('base64')Done.
And for "one-liner" fanboys, we can compact it into one line:
open(gimp.image_list()[0].filename, "rb").read().encode('base64')
bytes.encode('base64')
puts some new-line characters, alternatively you can use the following:
import base64 base64.b64encode(open(gimp.image_list()[0].filename, "rb").read())Reference: Python Scripting Official Doc
Thanks for this great post! Inspired by this (and in the need for such solution at my work) I've written today this plugin: https://github.com/sirmacik/gimp-plugin-base64_file_encoder
OdpowiedzUsuńHope others will find it useful too.
Cheers
Marcin
Thanks
OdpowiedzUsuńThanks for inspiring sirmacik who insired me https://github.com/CrandellWS/base64-gimp-plugin/releases
OdpowiedzUsuńDzięki za inspirującą sirmacik którzy mnie insired https://github.com/CrandellWS/base64-gimp-plugin/releases
If you're on a linux command line you can simply say
OdpowiedzUsuńbase64 -w 0 filename.png