Insert an Image from SQL DB to a report

I have an image in a DB saved with a base64 format. I need this image to be displayed at a report but I don't quite understand how to do it.

The image is well saved, since thrugh the console I saved that image directly in my computer and it worked.

This is how I am doing it right now:



Any idea what might be wrong? (I replied this post with more images and info, since I am new I can only upload 3 images per post)

I supposed that the image wasn't saved correctly at the DB. So I saved the signature image in my PC and as I expected the image is been saved correctly but no Idea why is not showing properly at the report.

This is the image saved at my computer:

If you really have saved the image in Base64 format, then try assigning the query result straight to data['signature']. IE don't do the replace and decode on lines 34 and 35.

That was my first try, didn't work. Then I read that Ignition reports just supports BLOB images. That's why I am doing the replace and then decode.

1 Like

Not sure if you found this post.

This one might be helpful as well
Image DataSource in Report , Ignition 7.9.10 - Ignition - Inductive Automation Forum

Thanks, but seems that it's not working I have no idea why is this happening. It shouldn't be that hard.

For a moment I believed that it was my DB, but I just made a test from another python script and put it inside a LaTeX report and it work perfectly. I guess this is an ignition issue or something I am not doing corectly.

I took another stab at this and figured it out this time. In your onSignatureSubmitted event use event.signatureFile.getBytes() and write that directly to your database as a blob, then the report will be able to display the image. In the last go around i think i was hung up on using event.signature

1 Like

Is it really the only way? I mean everything in my DB I am working it as JSON (since there are images not comming from Ignition too) and as JSON I need it to be in base64! If I do this change, then I have to re-write almost everything I have done :sweat_smile:

I have been with this issue since almost a week. I am getting kind of desesperate, is there any other way to do it? Like saving the image somewhere and from there extract it to the report?

I was reading that saving it in image management is not an option, also read that the report gather the image from the gateway so if I try to save it at the server then the image will not display at the report (unless I run the program always at the server which is not an option)

If there's any other idea I am open to it. It is kind of frustrating the way Reporting manage images.

Also if anybody knows if there's a thread, library or something where I can manage LaTeX I'll be open too, doing a report on LaTeX is way easier than this reporting program and I can grave images from there (base64 or BLOB).

Where did you get this information? You can save the image somewhere that the gateway has access to and then display it in a report from anywhere. I went this route when i couldn't figure out how to display a signature saved to a database the first time around.

You also could display a base64 encoded image but how you do that would depend on what flavor of SQL you are using. MySQL has FROM_BASE64 for example.