Display BLOB data from MySQL to image on Vision window

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.

Have you looked here?
Automation Professionals' Blob Server Module - 3rd Party Modules - Inductive Automation Forum

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.

1 Like

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.

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)

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