Is there a means to browse perspective images like system.tag.browse?

I am looking to load images into the management tool and have all the images from a directory be available in a dropdown. When I add a new image I want the dropdown to automatically update without me having to remember to update it myself.

I don’t see a means of doing this, hopefully I’m just overlooking something.

Thanks

To do this you would need to query the internal configuration db in Ignition. Its possible, but not really supported.

An alternate option would be to not use Image Management and instead WebDev. You can just put all the images in a dir and have an endpoint that will scan the directory and return all the file names.

2 Likes

As a general note, be 'scared' of endpoints that return filesystem information like this; make sure they're limited to a single directory and can't be exploited to return other directory information.

2 Likes

Use the ImageManager. Maybe .getImages() method is the one you need. Make the dropdown to execute the method each time you tap on it.

It sounds like the images are in a database, so I don’t think getImages() is going to work

No, the method is applied over the ImageManager. The only parameter you need is the root dir from the ImageManager point of view.

I ended up putting them in the filesystem at \Ignition\webserver\webapps\main. Then with Suprocess.popen communicate() I got a directory of the files.

I was able to reference them directly in Perspective’s image component since they were in the appropriate directory.

This is on a Windows Server box.

I would highly recommend using a Java filesystem access method over opening a secondary process and reading the output. Besides being substantially slower, it’s also more fragile and prone to errors.

2 Likes

OK , Paul, thanks, I had never done that before. It works great.

For other readers:

  • Documentation is in Ignition Libraries Documentation

  • The script console seems to have its filesystem namespace in my designer host, not the gateway,
    so you may not find the files you are expecting if you execute this there.

  • Startup Event script for a dropdown with all the images in it is:

	from java.io import File
	homePath = r"d:\Ignition\webserver\webapps\main"
	files = File(homePath)
	fileNames = files.list()
	dropdownSelections = []
	
	# Don't display extension with filename to user, replace on the image source binding
	displayFilenames = [x.replace(".jpg","").replace(".jpeg","") for x in fileNames]
	for jpeg in displayFilenames:
		dropdownSelections.append({"value":jpeg,"label":jpeg})
	self.props.options= dropdownSelections