I'm trying to process multi-page TIFs in an Azure Function. The function is triggered by changes in blob storage. When the trigger runs, it calls this:
function loadFile(Stream mpTif);
Bitmap pageOnes = (Bitmap)Image.FromStream(mpTif);
mpTif
is the blob storage Stream being passed directly into the Azure Function.
My function works fine on small multi-page TIF files but when I put a very large one in the blob storage, it fails on Image.FromStream
with the error:
Parameter is not valid
I am running this on my own machine using the local function host. The strange thing is that I have a console application which runs using the exact same code but calls it using a MemoryStream instead:
MemoryStream data = new MemoryStream(File.ReadAllBytes("big.tif"));
loadFile(data);
This works fine. Am I hitting some sort of memory limit in Azure Functions? It takes suspiciously long before I hit that error, which makes me think it's an OOM thing. This TIF file is very large (80Mb and 10,000 pages).