# Load image from DB into Image object

**URL:** <https://forum.inductiveautomation.com/t/load-image-from-db-into-image-object/12309>\
**Category:** Ignition\
**Created:** [October 31, 2016, 10:03pm UTC](https://forum.inductiveautomation.com/t/load-image-from-db-into-image-object/12309 "2016-10-31T22:03:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 31, 2016, 10:37pm UTC](https://forum.inductiveautomation.com/t/load-image-from-db-into-image-object/12309/2 "2016-10-31T22:37:20Z")

</div>

The following code will display a BLOB as the ‘icon’ on a Label component:

```python
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

image = # your readfileasbytes output
bais = ByteArrayInputStream(image)
bImageFromConvert = ImageIO.read(bais)
lbl3 = event.source.parent.getComponent('lblImage3')
boundWidth = lbl3.width
boundHeight = lbl3.height
originalWidth = bImageFromConvert.width
originalHeight = bImageFromConvert.height
newWidth = originalWidth
newHeight = originalHeight
if originalWidth > boundWidth:
	newWidth = boundWidth
	newHeight = (newWidth * originalHeight) / originalWidth
if newHeight > boundHeight:
	newHeight = boundHeight
	newWidth = (newHeight * originalWidth) / originalHeight
scaledImage = bImageFromConvert.getScaledInstance(newWidth,newHeight,Image.SCALE_SMOOTH)
lbl3.setIcon(ImageIcon(scaledImage))

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/load-image-from-db-into-image-object/12309)._
