I'm currently trying to generate a PDF report on my website with a bunch of images. All of those images are stored in an Azure blob storage in their original size.
Throughout the website I'm using the ImageResizer middleware with the Azure and DiskCache plugins and they work perfectly, however it seems that for the PDF report I have to use the ImageResizer API which will only accept a Stream, Bitmap or a path as input.
My current implementation technically works (which is downloading the blob and providing the stream), but it's very slow.
Is there a way to call the API while utilizing the disk-cache too? I've tried to provide paths like /azure/someblob.jpg but it doesn't work.
Edit: as per Natahniel's suggestion, I came up with this solution (for use with iTextSharp):
private Image GetImageResized(string path) {
var request = HttpContext.Current.Request.Url;
var uri = new Uri(request.Scheme + "://" + request.Authority + "/" + path, UriKind.Absolute);
Stream dest = null;
using (var client = new WebClient()) {
dest = new MemoryStream(client.DownloadData(uri));
}
return iTextSharp.text.Image.GetInstance(dest);
}
The path in this case would be something like azure/mycontainer/someblob.jpg?height=500
It should be something like /azure/path/to/document.pdf?format=png&page=1
Disk caching of Azure-provided PDF blobs is supported for the HTTP API, which would be best for this situation.