Accessing the Image management tool

Is it possible to call the “Image management tool”, that is avaiable in the designer, directly from a running application?
If not, how do I get a list of available images/thumbnails for the user to choose from or add to?

Unfortunately, the Image Managment tool is only available in the designer. What do you want to with the tool in the client?

We have an application that allows the “highlighting” of part of an image based on the status of that “area”. The idea of making the image manager available to the client (with suitable security that is) was so they can update/add/remove the images as needed without getting into the designer. Not that I don’t trust them, well actually… I don’t. :unamused:
If this is not available to the client can you please give me some ideas as to how I can achieve similar functionality in a client window (i.e. browse, select, add, and remove images from the gateway.) :prayer:

The only way to get that functionality right now is to put the images (image paths) in a dataset on the window. Of course, this means you need to select all of the images ahead of time. Once you have that, you can dynamically run through the images in the dataset in the client selecting the images you need. Hope this helps.

Hello @Travis.Cox ,
I’ve the same need for a Perspective application.
Users need to select an image to fill a form.
For now, my image list is a manual dataset and in the futur, it would be nice to be able to list by script the image list of a folder in Image management tool.

Otherwise, I’ll have to host them elsewhere (filesystem or database) to dynamically build my dataset.

This is the way that is generally supported at the moment. Either by storing the files in a DB or exposing them via the WebDev module.

You can also put the images in <Install Dir>\Inductive Automation\Ignition\webserver\webapps\main and then pull them in via bindings etc. See here for more information.

If you really want to use the image management tool, the following two scripts might help. They work in 8.1, some mods are required in the message handler for earlier versions. The methods are not supported.

Script 1 sends image data from the client to a message handler(image_upload) on the gateway:

from java.awt import Toolkit
from java.io import File
from org.apache.commons.io import FilenameUtils
import imghdr

filepath = event.source.parent.getComponent('File Explorer').selectedPath

payload = {}
payload['image_name'] = File(filepath).name.replace(' ','')
payload['image_desc'] = None

#  Valid image types PNG, JPEG, GIF, BMP, fix this in the message handler
payload['image_type'] = imghdr.what(str(filepath)).upper()

#  Important to end the folder name with a /
payload['folder'] = "%s/" % folder_name

javaImage = Toolkit.getDefaultToolkit().getImage(filepath)
payload['width']      = javaImage.width
payload['height']     = javaImage.height
payload['size']       = File(filepath).length()
payload['image_data'] = system.file.readFileAsBytes(filepath)

#  Call the gateway event script message handler, named image_upload on this project
proj = system.tag.read("[System]Client/System/ProjectName").value
status  = system.util.sendRequest(proj, 'image_upload', payload)

Script 2, a gateway message handler named image_upload, puts the image data into the image management tool:

 	from com.inductiveautomation.ignition.gateway import IgnitionGateway
 	from com.inductiveautomation.ignition.gateway.images import ImageFormat
 	
 	context = IgnitionGateway.get()
 	image = context.getImageManager()
 
 #	1  Valid image types PNG, JPEG, GIF, BMP, fix this in the message handler
 	image_type = {
 		'PNG' : ImageFormat.PNG,
 		'JPG' : ImageFormat.JPEG,
 		'JPEG': ImageFormat.JPEG,
 		'GIF' : ImageFormat.GIF,
 		'BMP' : ImageFormat.BMP}[payload['image_type']]
 
 	image.insertImage(payload['image_name'], payload['image_desc'], image_type, payload['folder'], payload['image_data'], payload['width'], payload['height'], payload['size'])
 	
 	return

These are also posted at Image Management Tool - #19 by mcgheeiv along with a bunch of development clues.

Thanks all for your help.

Do you know if I can use these library in a Perspective view to list all images from a folder and fill my Dataset?
https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.1/com/inductiveautomation/ignition/gateway/images/package-summary.html

Yes, it is possible to access the ImageManager using the SDK API. You can get all of the images or upload new oens. For example, you can do this:

from com.inductiveautomation.ignition.gateway import IgnitionGateway
context = IgnitionGateway.get()
imageManager = context.getImageManager()

You can look at the JavaDocs here:

https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.1/com/inductiveautomation/ignition/gateway/images/ImageManager.html

The script has to run on the Ignition Gateway (server) in order to access that API. Also, the API is subject to change in the future so you will want to test the script after any upgrades or track the changes in the API.