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.