# Insert an Image from SQL DB to a report

**URL:** <https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163>\
**Category:** Ignition\
**Tags:** reporting\
**Created:** [August 26, 2024, 5:35pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163 "2024-08-26T17:35:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos\_Estrada](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Carlos\_Estrada](https://forum.inductiveautomation.com/u/Carlos_Estrada)\
**Post date:** [August 26, 2024, 5:35pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/1 "2024-08-26T17:35:55Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/243ac5e688b7c050e74d2eb6ad504935ceff072c.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/8/4888348517d26fc3d2f0ffcdb575c66ba9a5d651.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/e/8e0b80651357d9b9d6234f83d36b3e355db2ca6f.png)

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)

---

<div class="post-metadata">

**Author:** ![Carlos\_Estrada](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Carlos\_Estrada](https://forum.inductiveautomation.com/u/Carlos_Estrada)\
**Post date:** [August 26, 2024, 5:40pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/2 "2024-08-26T17:40:20Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/2/328264ca18fe73b9d8a81b6eb33c1edd6f5a6576.png)

This is the image saved at my computer:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/8/98a0f2ad2bd36c7414aa3a8345a9111895ee6454.png)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 26, 2024, 5:59pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/3 "2024-08-26T17:59:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Carlos\_Estrada](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Carlos\_Estrada](https://forum.inductiveautomation.com/u/Carlos_Estrada)\
**Post date:** [August 26, 2024, 6:08pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/4 "2024-08-26T18:08:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 26, 2024, 6:28pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/5 "2024-08-26T18:28:28Z")

</div>

Not sure if you found this [post.](https://forum.inductiveautomation.com/t/base-64-images-in-report/49314)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 26, 2024, 6:41pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/6 "2024-08-26T18:41:35Z")

</div>

This one might be helpful as well  
[Image DataSource in Report , Ignition 7.9.10 - Ignition - Inductive Automation Forum](https://forum.inductiveautomation.com/t/image-datasource-in-report-ignition-7-9-10/47387)

---

<div class="post-metadata">

**Author:** ![Carlos\_Estrada](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Carlos\_Estrada](https://forum.inductiveautomation.com/u/Carlos_Estrada)\
**Post date:** [August 26, 2024, 9:44pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/7 "2024-08-26T21:44:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [August 26, 2024, 10:44pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/8 "2024-08-26T22:44:11Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![Carlos\_Estrada](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Carlos\_Estrada](https://forum.inductiveautomation.com/u/Carlos_Estrada)\
**Post date:** [August 26, 2024, 11:48pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/9 "2024-08-26T23:48:46Z")

</div>

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 😅

---

<div class="post-metadata">

**Author:** ![Carlos\_Estrada](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Carlos\_Estrada](https://forum.inductiveautomation.com/u/Carlos_Estrada)\
**Post date:** [August 26, 2024, 11:56pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/10 "2024-08-26T23:56:40Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [August 27, 2024, 6:48pm UTC](https://forum.inductiveautomation.com/t/insert-an-image-from-sql-db-to-a-report/95163/11 "2024-08-27T18:48:38Z")

</div>

> [@Carlos\_Estrada](#):
>
> so if I try to save it at the server then the image will not display at the report

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.
