# 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:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [June 12, 2024, 6:04pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/1 "2024-06-12T18:04:25Z")

</div>

I know image management has long been discussed here, but I can not find any solution that works well..

1. I am uploading an image in perspective. I want to be able to display that image again in perspective.

2. I cannot find any doc's on programmatically storing that image with the Image Manager.

3. I don't want to use any BLOBS with databases.

4. I have managed to save the image to a drive on the Gateway, but servicing them to a perspective session is proving to be troublesome, unless someone know a magic folder that can be viewed in [http://example:8088/image.png](http://example:8088/image.png)

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Steven\_Cheron](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@Steven\_Cheron](https://forum.inductiveautomation.com/u/Steven_Cheron)\
**Post date:** [June 12, 2024, 6:12pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/2 "2024-06-12T18:12:21Z")

</div>

I don't know if you can import image by script in the image manager.

But one solution is to save the image in a folder somewhere.  
And then with the WebDev module (or a custom web server like Flask with Python, if you don't have the WebDev module) give access to your image. These image will be available with an URL like your 4th point.

---

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [June 12, 2024, 6:17pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/3 "2024-06-12T18:17:10Z")

</div>

Thank you. I am trying to not use WebDev

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 12, 2024, 6:18pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/4 "2024-06-12T18:18:33Z")

</div>

> [@Thomas\_Salisbury](#):
>
> I don't want to use any BLOBS with databases

and

> [@Thomas\_Salisbury](#):
>
> Thank you. I am trying to not use WebDev

seriously limit your ease of doing this.

A blob in the database coupled with a WebDev resource, or @pturmel Blob module is the most efficient Ignition centric way to get this done (that I know). Anything else would be either unsupported, or fragile and prone to breaking in future version.

The Ignition image management stores the data in a database as well... just SQLite rather than a robust database.

---

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [June 12, 2024, 6:21pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/5 "2024-06-12T18:21:01Z")

</div>

I understand all this, but using the getBytes() to store in an MSSQL column and then pulling it back out seems to AWAYS crash either my designer, or the whole gateway. If someone could point me to a resource of examples that work in this regard, I could revisit that.

---

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [June 12, 2024, 6:22pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/6 "2024-06-12T18:22:05Z")

</div>

also @pturmel module seems to no longer be available... the link is crossed out

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 12, 2024, 6:33pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/7 "2024-06-12T18:33:25Z")

</div>

That is typically a memory issue on the gateway side. You might try increasing gateway memory and seeing if that helps.

We do this frequently with PDFs with no issue.

For the module hopefully, @pturmel will chime in with a valid link.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 12, 2024, 6:39pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/8 "2024-06-12T18:39:21Z")

</div>

> [@Automation Professionals' Blob Server Module](https://forum.inductiveautomation.com/t/automation-professionals-blob-server-module/57970/47):
>
> Sure. Easy-peasy, I think. Try this: [v1.1.0.231421939](https://www.automation-pros.com/ignition/Blob%20Serve-1.1.0.231421939-v81.modl) Return an optional third column, ContentDisposition, from your named query with your desired header content. Be sure to embed the quotes into the value if you supply the filename.

---

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [June 12, 2024, 6:58pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/9 "2024-06-12T18:58:18Z")

</div>

Crashed my designer and gateway....

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 12, 2024, 7:00pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/10 "2024-06-12T19:00:20Z")

</div>

Can you grab something from the logger showing the error? You may need to get into the wrapper.log to get the error as it was crashing.  
How big is the file you are uploading?  
Can you post your code?

---

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [June 12, 2024, 7:02pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/11 "2024-06-12T19:02:59Z")

</div>

Th image is 970kb

---

<div class="post-metadata">

**Author:** ![aaronrai24](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aaronrai24/32/87248_2.png) [@aaronrai24](https://forum.inductiveautomation.com/u/aaronrai24)\
**Post date:** [June 12, 2024, 7:08pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/12 "2024-06-12T19:08:54Z")

</div>

If you are curious how to work with ImageManagement programmatically you have to use the [ImageManager](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.42-rc1/com/inductiveautomation/ignition/gateway/images/ImageManager.html).

You can get the ImageManager context like:

```python
context = IgnitionGateway.get()
image = context.getImageManager()

```

This then give you access to use the functions getImage, getImages, insertImage, deleteImage like from the javadoc I linked. Keep in mind I believe you have to be gateway scoped but since you tagged perspective you should be fine

---

<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)

---

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [June 12, 2024, 7:13pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/14 "2024-06-12T19:13:16Z")

</div>

I updated, but now it just shows the binary data in the html..

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 12, 2024, 7:24pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/15 "2024-06-12T19:24:22Z")

</div>

So you have it uploading?  
But pulling it out isn't working?  
How are you pulling it out? With @pturmel module?

---

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [June 12, 2024, 7:30pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/16 "2024-06-12T19:30:32Z")

</div>

Correct. I am using MSSQL, so I don't think its going to work

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 12, 2024, 7:33pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/17 "2024-06-12T19:33:08Z")

</div>

I believe it should work just find with MSSQL. As long as the columns are setup correctly.

Can you show how you setup the database table?

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [June 12, 2024, 7:54pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/18 "2024-06-12T19:54:47Z")

</div>

I have used the Blob serve module before with MSSQL many times and it's always worked for me. v19 and v2022.

---

<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:** [June 13, 2024, 1:26am UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/19 "2024-06-13T01:26:25Z")

</div>

> [@Thomas\_Salisbury](#):
>
> the link is crossed out

I mark links like that when they've been replaced by newer versions. Simply scroll further into the topic.

---

<div class="post-metadata">

**Author:** ![Thomas\_Salisbury](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomas_salisbury/32/62046_2.png) [@Thomas\_Salisbury](https://forum.inductiveautomation.com/u/Thomas_Salisbury)\
**Post date:** [June 13, 2024, 12:18pm UTC](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770/20 "2024-06-13T12:18:55Z")

</div>

```python
CREATE TABLE asset_images (
    id INT IDENTITY PRIMARY KEY,
    assetId INT NOT NULL,
    name VARCHAR(255) NOT NULL,
    Content VARBINARY(MAX) NOT NULL,
    ContentType VARCHAR(25) NOT NULL,
    uploadDate DATETIME DEFAULT GETDATE(),
    fileSize INT
    FOREIGN KEY (assetId) REFERENCES assets(id) ON DELETE CASCADE
);

```

```python
SELECT Content, ContentType
FROM asset_images
WHERE id = :id

```

[Next page](https://forum.inductiveautomation.com/t/image-manager-storing-images-dynamically/91770.md?page=2)
