LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Image to PNG Data slows down web service

 

While developing a web service that is to stream a PNG image of a graph, I discovered a rather peculiar effect.

 

It seems that the output from the LV Image to PNG Data.vi in the NI_Webservices.lvlib causes a problem if it is used to send the image of a graph (read using the get image method) through the Write Response.vi from the same lvlib. This only happens with graphs...and the effect is that it takes about 30 seconds or more for the web browsers to load the received image.

20127iB450F32670C24256

 

 

If you write the same image to disk and then send the contents of that file (again using Write Response) the problem disappears:

 

20129i2CC55EDD59338F96

 

 

 

The problem however does not seem to be in the execution of the LV Image to PNG Data.vi itself - because if you still run it prior to writing the response (but do not use its output - instead you send the image generated using the file method)  it will not affect the response time.

 

There must be something in the data stream generated by LV Image to PNG data that is wrong when it is used on graph images, because if it is used with images of other indicators the slowdown does not occur. It would be more understandable if this was just due to the size of the image (compared to e.g. the image of a numeric indicator) , but even if the graph is made very small the LV Image to PNG method will still cause the same delay.

 

Has anyone else seen this and know why it happens? Is it a bug in the output of the LV Image to PNG Data.vi?

 

 I'm fine with the "write to png file and read it back" method now, but it was a bit of work to figure out why the web service was so slow - and if that's how it works for everyone I am sure it will cause plenty of headaches.

 

 

0 Kudos
Message 1 of 3
(3,062 Views)

I don't have direct experience, but have you tried changing the compression level when using Write PNG File.vi? 

 

LV Image to PNG Data.vi does not support a compression input; maybe the default used internally is different than that of Write PNG File.

 

PNG is lossless. The image viewed by the web client should be the same; the only difference would be the compression. Compare the length of the strings from LV Image to PNG Data.vi and the string data read from the file.

 

You could enter a request in the Idea Exchange if the ability to select the compression would be of use...


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 2 of 3
(3,049 Views)

No compression used I'm afraid...I tried changing that to see if it had any effect if I did add compression, but no.

0 Kudos
Message 3 of 3
(3,007 Views)