# Display BLOB data from MySQL to image on Vision window

**URL:** <https://forum.inductiveautomation.com/t/display-blob-data-from-mysql-to-image-on-vision-window/70084>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [February 20, 2023, 8:02pm UTC](https://forum.inductiveautomation.com/t/display-blob-data-from-mysql-to-image-on-vision-window/70084 "2023-02-20T20:02:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lcs226](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lcs226](https://forum.inductiveautomation.com/u/lcs226)\
**Post date:** [February 20, 2023, 8:02pm UTC](https://forum.inductiveautomation.com/t/display-blob-data-from-mysql-to-image-on-vision-window/70084/1 "2023-02-20T20:02:33Z")

</div>

I am looking for direction on how to display Blob data I have stored in my DB. I have reviewed the forum and have not been able to find a solution that works or that is not missing information on a complete solution. Any help please.

---

<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:** [February 20, 2023, 8:05pm UTC](https://forum.inductiveautomation.com/t/display-blob-data-from-mysql-to-image-on-vision-window/70084/2 "2023-02-20T20:05:04Z")

</div>

Have you looked here?  
[Automation Professionals' Blob Server Module - 3rd Party Modules - Inductive Automation Forum](https://forum.inductiveautomation.com/t/automation-professionals-blob-server-module/57970)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 20, 2023, 8:07pm UTC](https://forum.inductiveautomation.com/t/display-blob-data-from-mysql-to-image-on-vision-window/70084/3 "2023-02-20T20:07:04Z")

</div>

That's not really intended for Vision. Vision can call such a Named Query directly and obtain the bytes from the resulting dataset. From there it is identical to the various examples on this forum for displaying image files in Vision's paintable canvas.

---

<div class="post-metadata">

**Author:** ![automatisation](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@automatisation](https://forum.inductiveautomation.com/u/automatisation)\
**Post date:** [February 21, 2023, 2:38pm UTC](https://forum.inductiveautomation.com/t/display-blob-data-from-mysql-to-image-on-vision-window/70084/4 "2023-02-21T14:38:20Z")

</div>

Snippet of the code we use here to display some images from the DB. This code resize the blob to the component size.  
Was stolen and adapted from other topics.

```auto
from javax.swing import ImageIcon
from java.io import ByteArrayInputStream
from javax.imageio import ImageIO
from java.awt import Image
from java.net import URL
from java.io import File

comp = event.source.parent.getComponent('image_display')

if blob:
	bais = ByteArrayInputStream(blob)
	bImageFromConvert = ImageIO.read(bais)
	
	if comp.width > comp.height:
		comp_l = comp.height
		comp_h = comp.width
	else:
		comp_l = comp.width
		comp_h = comp.height
		
	bdd_l = bImageFromConvert.width
	bdd_h = bImageFromConvert.height
	
	img_l = int(1.0 * comp_h * bdd_l / bdd_h)
	img_h = int(1.0 * comp_l * bdd_h / bdd_l)
	if img_l > comp_l:
		img_l = comp_l
	if img_h > comp_h:
		img_h = comp_h
	
	img = bImageFromConvert.getScaledInstance(img_l, img_h, Image.SCALE_SMOOTH)
	comp.setIcon(ImageIcon(img))
else:
	comp.setIcon(None)

```

---

<div class="post-metadata">

**Author:** ![lcs226](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lcs226](https://forum.inductiveautomation.com/u/lcs226)\
**Post date:** [February 27, 2023, 2:40pm UTC](https://forum.inductiveautomation.com/t/display-blob-data-from-mysql-to-image-on-vision-window/70084/5 "2023-02-27T14:40:27Z")

</div>

Thanks for the feedback.  
What component was this used on and where was this code applied
