Report Images and WebDev

I have a report that has dynamic images. I used to return the bytes in a dataset and bind those to the Key of the image. The issues is that this would cause Java Heap issues as the memory used would not cleanup terribly great.

At the suggestion of Tech Support, I have moved to using the webdev module to host the images. I use this now throughout the project (Vision and Perspective) and I can tell you it is much faster and much cleaner way of working with images.

I have one last problem that I have not been able to resolve. in that I cannot get the images to display in the table in the report. Imagine a picture for each result in the dataset. The dataset has a column where the url is being formed

I can use the sample url from the documentation for the report viewer and everything works fine, but my webdev script is not working. Not sure how to go about troubleshooting it from here.

URL: (tried with and without double quotes)

"http://stolignition:8088/main/system/webdev/Global_Equip/EquipmentFiles?ID=18"

WebDev Code to generate image:

params = request['params']
	ID = params['ID']
	
	
	data = system.db.runScalarPrepQuery("select fileData from files where file_id = ? ",[ID])
		
	return {'bytes': data}
			

You could try to open it in a browser, and check if it’s your webdev part that isn’t working.

In the browser, open the developer console (Ctrl+shift+i in Firefox or Chrome), go to the network tab, and check what happens when you visit that URL (if you get an HTTP error, or if your browser is able to render it).

The first thing I expect here, is that the response is missing headers. An image usually needs an appropriate Content-Type header, like Content-Type:image/jpg (depending on how the image is encoded).

Edit: apparently, it’s a bit hidden in the docs on how to add a content type. You can just add a contentType key to the result dictionary.
(Web Dev - Ignition User Manual 7.9 - Ignition Documentation)

[The contentType key] may be included with any of the other keys to override the default content type.

I’ve changed the return to the following:

return {'contentType':'image/jpg','bytes': data }

The image is displayed in the browser just fine, but still no images being displayed in the report. I confirmed that other image components in Vision are working just fine with the source property bound to the URL

@djones, I’m wondering if you’ve found a solution for dynamic images in reports?

Just return the bytes in the query in the report. The report can render the images directly from the data from a query, no need to complicate things with using webdev. The data key for the image should be set to the bytes column for the image.

1 Like

I believe the original problem with simply querying images from the database and displaying them on the report was heap space and performance issues, for which the solution was to use the WebDev module which uses a byte stream that should help in that regard.

The webdev would help for heap issues in Vision, and payload encoding inefficiencies in Perspective, but the report generator runs entirely in the gateway and will use the heap space anyways.

Have you had success in getting a dynamic WebDev image to display in a report?

It appears a static image path works (i.e. “http://:/main/system/webdev//.jpg”), but as soon as a python resource is used with a dynamic property (i.e. “ID” in python resources below) nothing is displayed, even though the same url works on an image in perspective.

Python Resource (doGet):

params = request['params']
ID = params['ID']
intID = int(ID)
data = system.db.runScalarPrepQuery("SELECT image FROM tickets WHERE (id=?)", [intID], 
    'MariaDB')
return {'contentType':'image/jpg','bytes': data}

URL:
“http://:/main/system/webdev//python?ID=2”

Again, the url works on a Perspective Image Source, does not work on a Report image key (with or without quotes).

Any help on getting a WebDev python resource to display on a report would be helpful.

Once it is working we will see if we have better results than simply querying the image from the db… In the end we would like to display many images which is where we run into payload/heap space limitations.

Yes! Forgot about this. We have this problem as well, we have some internal documentation that is auto-generated via reporting with lots of big images, but to get around the heap space issues, we just schedule the report generation on the gateway and dump the output to a shared folder so the users are not actually executing the report in Vision. If they NEED to see the report in vision, we serve it up over WebDev to the client.