# Image manager - storing images dynamically

**URL:** <https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 12, 2024, 6:04pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770 "2024-06-12T18:04:24Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Noah\_Casey](https://avatars.discourse-cdn.com/v4/letter/n/e480ec/32.png) [@Noah\_Casey](https://forum.inductiveautomation.com/u/Noah_Casey)\
**Post date:** [June 12, 2024, 7:09pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/13 "2024-06-12T19:09:31Z")

</div>

```python

	from javax.imageio import ImageIO
	from java.io import ByteArrayInputStream
	from com.inductiveautomation.ignition.gateway.images import ImageManager, ImageFormat
	from com.inductiveautomation.ignition.gateway import IgnitionGateway

	# Obtain the GatewayContext
	gatewayContext = IgnitionGateway.get()
	# Get the ImageManager
	imageManager = gatewayContext.getImageManager()
	
	imageBytes = event.file.getBytes()
	# Convert the image bytes to a ByteArrayInputStream
	byte_stream = ByteArrayInputStream(imageBytes)
	# Use ImageIO to read the image from the byte stream
	buffered_image = ImageIO.read(byte_stream)
	
	# Get the width and height of the image
	width = buffered_image.getWidth()
	height = buffered_image.getHeight()
	# Other Variables
	Name = event.file.name
	Description = event.file.name
	Imagetype = ImageFormat.PNG
	directory = ''
	#ImageType = event.file.name.split('.')[-1].upper()
	inputfile = imageBytes
	size = len(inputfile)
	
	#Upload to image manager
	imageManager.insertImage(Name,Description,Imagetype,directory,inputfile,width,height,size)
	
	
	

```

I wrote this code it goes directly into the file upload component this was a fast mock up so if you want security and verification I would add a button that runs this script.

Here is the example in use:

![ShowingImageUpload](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/f/8fceef7d637c2e97a04bebfb9d8ca461b585c291.gif)

It also directly uploads to the image management tool in Ignition  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/4/84a14483d2e435c397b86a130ecd44ad1d05af07.png)

---

_[View the full topic](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770)._
