Yes, the community commons has a java function for that: https://appstore.home.mendix.com/link/app/170/Mendix/Community-Commons-Function-Library
Base64EncodeFile - Converts an unencode file to a base 64 encoded string.
So you can convert any filedocument (so also an image document) to a base64 encoded string.
Regards,
Ronald