What's next? verify your email address for reply notifications!
You can also use file -Ib (--mime --brief) to get a mime type:
echo "data:$(file -Ib "$1" | sed 's/ //g;s/;charset=binary$//');base64,$(base64 "$1")"
Printing the dimensions of images with ImageMagick:
identify -format '%w x %h' file.png
great tips. I didn't know file could do mime type like that.