private Task <byte[]> downloadImage(ThumbnailRequest request, string url) { var trackingId = request.Srv.TrackingId; byte[] download() { try { _log.info(trackingId, () => $"Downloading '{url}'"); using (var web = new WebClient()) { return (web.DownloadData(url)); } } catch (Exception ex) { _log.error(trackingId, ex, $"Failed to download '{url}' ({ex.Message})"); return (_helpers.TextToImage(request.Width, request.Height, $"{ex.Message} (trackingId={trackingId})")); } } return (Task.Run(() => download())); }
private Image mem2image(string trackingId, MemoryStream mem) { try { return (Image.FromStream(mem)); } catch (Exception ex) { _log.error(trackingId, ex, $"Failed to create image from data; {ex.Message}"); return(null); } }