Question on Downloading an Image as JPG From Created From Retool AI

Hi,

Within my application, I can render an image that Retool AI has generated using the base64 data string, but I'd like to have the end user be able to click the image and save the picture as a JPG or PNG instead of a base64 encoded image/png. Is that possible?

Currently, I'm using this code within the click event handler, which works to download the image, but the image is still in base64 which makes sense from the first line of the code, but any time I've tried modifying the image/png to image/jpg or changing the base64 I'm unable to render the image. Thank you in advance for any help!

Current Code

utils.downloadFile(
  { base64Binary: <my image from retool al>.data },
  "filename", 
  "image/png");

Hi @Cbrooks88,

I'd use 'png' instead of 'image/png'

The below code is working for me:

utils.downloadFile({base64Binary: aiImageQueryName.data},'filename','png')

well ive learned something today lol. do you happen to know if downlaidFile ends up using the the base64 to make a blob to dl (since its a binary-ish tupe) and if so do other file type conversions work?

ive seen this specific conversion before, but it used a temp canvas element to load the jpg then .toDataUrl() to convert to blob with new file type.

seeing whats essentially a dynamic cast (forced polymorphism?) without any indication will probably always catch me off guard lookin like a deer in headlights