Last post Jun 09, 2020 05:24 AM by SasikalaSankaran
Jun 01, 2020 10:20 AM|SasikalaSankaran|LINK
I am using AsyncFileUpload controls to upload jpg, jpeg, png, gif and svg file and resize the image to display as thumbnail on the application screen. I am able to resize all the image formats except svg.
In AsyncFileUpload_UploadedComplete Method I am calling a function that will resize the original image to Thumbnail.
GenerateThumbnail(AsyncFileUpload.PostedFile.InputStream, AsyncFileUpload.PostedFile.ContentType, thumbFilename, fileGuid);
private void GenerateDBThumbnail(Stream source, string contentType, string imageName, string fileGuid)
if (contentType.ToLower().IndexOf("image/") < 0) return;
using (var image = Image.FromStream(source))
// Image resize;
For svg file error hits in the line: using (var image = Image.FromStream(source)) as " Parameter is not valid".
Kindly help me on this.
Jun 01, 2020 01:08 PM|Mikesdotnetting|LINK
An svg file is not a supported Image file. It is an XML file. You could use the browser to convert it: https://stackoverflow.com/questions/3975499/convert-svg-to-image-jpeg-png-etc-in-the-browser
Jun 09, 2020 05:24 AM|SasikalaSankaran|LINK
Thanks for your reply. Finally I was able to achieve thumbnail for SVG image file by converting it in to png.
Implemented as per the below link.
instead of saving as bmp, I passed the file as stream to convert to thumbnail.
using (MemoryStream memory = new MemoryStream())
using (FileStream fs = new FileStream(outputFileName, FileMode.Create, FileAccess.ReadWrite))
byte bytes = memory.ToArray();
fs.Write(bytes, 0, bytes.Length);
For this I have installed SVG package from NuGet.
Now the problem is when I check in the code in Git, it is successful, but the pipeline fails giving the below error, as this is a Website application, the package,config is checked in and build succeeded but Deployment fails. As this is a Website application
the dll automatically added into bin, and package.config. So implemented in the asp.net page with Using Svg;
error CS0246: The type or namespace name 'Svg' could not be found (are you missing a using directive or an assembly reference?)
Issue resolved by pushing the Svg and its dependent dlls to Git.