# Displaying an image from a database in Perspective (without Blob modules or WebDev)

**URL:** <https://forum.inductiveautomation.com/t/displaying-an-image-from-a-database-in-perspective-without-blob-modules-or-webdev/117185>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 25, 2026, 1:08am UTC](https://forum.inductiveautomation.com/t/displaying-an-image-from-a-database-in-perspective-without-blob-modules-or-webdev/117185 "2026-09-25T01:08:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaloyan\_Radomirov](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kaloyan\_Radomirov](https://forum.inductiveautomation.com/u/Kaloyan_Radomirov)\
**Post date:** [September 25, 2026, 1:08am UTC](https://forum.inductiveautomation.com/t/displaying-an-image-from-a-database-in-perspective-without-blob-modules-or-webdev/117185/1 "2026-09-25T01:08:25Z")

</div>

I was looking for a simple way to display an image stored in a database inside Perspective, and I accidentally found a very clean solution.  
No Blob module, no WebDev, no endpoints — just pure Python inside a component change script.

This approach works with DB column containing raw image bytes (BLOB).

## **Named Query example**

**Query name:** `img_select`  
**Path:** `MyProject/img_select`

sql

```python
SELECT img AS "Content", 'image/png' AS "ContentType"
FROM MyTable
WHERE description = :name

```

## **Perspective change script example**

python

```python

import base64

result = system.db.runNamedQuery("MyProject", "img_select", {"name": currentValue.value})
content = result.getValueAt(0, "Content") if result.getRowCount() else None

# If no image → send a 1×1 transparent PNG
if not content or len(content) == 0:
    blank_png_base64 = (
        "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8"
        "/w8AAn8B9p2u3wAAAABJRU5ErkJggg=="
    )
    value = "data:image/png;base64," + blank_png_base64
    self.getSibling("Image").props.source = value

else:
    # Convert BLOB → base64
    b64 = base64.b64encode(content).decode("utf-8")
    value = "data:image/png;base64," + b64

    # Send to the Image component
    self.getSibling("Image").props.source = value

```

## **Notes**

- No WebDev or file endpoints needed.

- The Image component accepts base64 directly via `props.source`.

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [September 25, 2026, 1:18am UTC](https://forum.inductiveautomation.com/t/displaying-an-image-from-a-database-in-perspective-without-blob-modules-or-webdev/117185/2 "2026-09-25T01:18:28Z")

</div>

It would be even more clean if you didn’t import “system” in your script. This is normally an artifact of AI writing code…

That aside, this is effectively the normal way that database image retrieval works in Perspective, and this also works in the Reporting module as well.  
The Blob server module has specific use cases that aren’t always needed, but when you need it, you can’t easily AI script around it.

---

<div class="post-metadata">

**Author:** ![Kaloyan\_Radomirov](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kaloyan\_Radomirov](https://forum.inductiveautomation.com/u/Kaloyan_Radomirov)\
**Post date:** [September 25, 2026, 2:47am UTC](https://forum.inductiveautomation.com/t/displaying-an-image-from-a-database-in-perspective-without-blob-modules-or-webdev/117185/3 "2026-09-25T02:47:14Z")

</div>

Good point — the `import system` line isn’t needed in Perspective scripts, so I removed it. And yes, this is the standard way to pull images from a DB in Perspective. Blob Server is only required for the cases where base64 isn’t enough.
