This project has moved. For the latest updates, please go here.

Read() function occasionally locking up for 10+ seconds when grabbing image from URL

Sep 23, 2015 at 7:52 PM
Edited Sep 23, 2015 at 8:00 PM
So I am continuously grabbing jpeg images from a camera with a command such as follows: MagickImageCamera.Read("http://207.251.86.238/cctv18.jpg")
(note this is an actual public camera I found on the Internet)

I am performing this action every 2 seconds. I tracked down the delay to the Read() function.
The locking up usually occurs every minute or so.

As an alternative to the read function I tried using the New command for every call instead, but got the same locking up using;
Using MagickImageCamera As New MagickImageCamera(http://207.251.86.238/cctv18.jpg”)

I should also point out that when the Read() function is locked up I am able to go to the URL of the jpeg in a web browser and refresh the image just fine.

So is there a way I can stop the Read() from locking up?
Coordinator
Sep 24, 2015 at 7:43 PM
Edited Sep 24, 2015 at 7:43 PM
ImageMagick uses the method URLDownloadToFile(https://msdn.microsoft.com/en-us/library/ms775123(v=vs.85).aspx) to download the image to disk and then reads it. I did a quick google search and it looks like more people run into locks/timeout issues. There is no real benefit to use an url directly because it is first stored in a file and then read from disk. You will probably get a better performance if you use the default tools of .NET to download a file into a MemoryStream and then 'feed' in to Magick.NET. You will not have any disk IO if you do that.
Sep 25, 2015 at 6:42 PM
Edited Sep 25, 2015 at 6:43 PM
Thanks, I took your suggestion and are feeding a Stream to Magick.Net. All is working good. In addition, while before the code was pushing the use of 200mb of memory, now it is topping out at around 50 mb. That URLDownloadToFile() method seems like a real hog in cases where it needs to be used repeatedly.