Perspective client to display image from FTP server with scripting

Hello,

I need to make my Ignition 8.1 Perspective client display an image file that is stored on an FTP server.
The image file name is dynamically determined by scripting.
I tried to pass the URL to system.perspective.navigate, but unfortunately the web browsers don’t seem to support FTP anymore.
If I download the image file with ftplib.ftp.retrbinary and save it in an image file could I display it somehow through scripting?

Thank you!

You can make a WebDev endpoint that performs the FTP retrieval. You should consider not using FTP anymore. If you store your images in a DB, you could use my free Blob Server module instead.

1 Like

Thank you for taking the time to answer my question.
I will try to install the WebDev module.
I don’t have much of a choice with the FTP as this is the only way that we can get the KEYENCE cameras to save the images on the network.

Keyence cameras have a command channel that can be used to retrieve images. What model do you have?

We have KEYENCE XG-X 1200

That model’s communication command reference doesn’t list the BR command to retrieve image data. I can’t find any commands that move image data over the command channel at all. Keyence appears to have moved all of that traffic to the undocumented ActiveX interface. ):

1 Like

It is what it is.
Just frustrating that there are at least two simple ways to do this task (download the image and display it in an Image Component or load the URL in a Web Browser Component) in Vision and none that I can figure out in Perspective. I was really hoping that I can get some ideas on the Forum.

I guess I’m a little confused as to why you can’t use an Image component?

Taken from the manual Perspective - Image - Ignition User Manual 8.1 - Ignition Documentation

Specifically It could be a URL to an image on the internet.

1 Like

When I put the following URL in the props.source of the Image Perspective Component, no image gets displayed:
ftp://username:password@ip_address/path/filename.jpg

Your browser likely doesn’t allow cross-origin requests on the same page. That’s for legitimate security reasons. There’s not a lot for Ignition/Perspective to do about it.

I’m guessing you could retrieve via ftplib as you noted, save to DB, and display with @pturmel’s Blob Server module if you don’t want to use WebDev.

2 Likes

Hello again,

If anyone is wondering how to do this, I can share another way that worked for us.
I ended up using the ftplib library to download the image file into a bytearray then encoded it into base64 and used it to embed the image into the Image Component source like this:

self.getChild('Image').props.source = 'data:image/jpeg;base64, %s' % base64.b64encode(imageDataBytes)

The images displayed are dynamically generated and ephemeral which is why I didn't want to store them again in a database or a web server.

1 Like