I having an issue while converting to vb using https://converter.telerik.com/ Error Message: Type of 'image' cannot be inferred from an expression containing 'image'
Private Sub GenerateThumbnails(ByVal scaleFactor As Double, ByVal sourcePath As Stream, ByVal targetPath As String)
Using image = Image.FromStream(sourcePath)
Dim newWidth = CInt((image.Width * scaleFactor))
Dim newHeight = CInt((image.Height * scaleFactor))
Dim thumbnailImg = New Bitmap(newWidth, newHeight)
Dim thumbGraph = Graphics.FromImage(thumbnailImg)
thumbGraph.CompositingQuality = CompositingQuality.HighQuality
thumbGraph.SmoothingMode = SmoothingMode.HighQuality
thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic
Dim imageRectangle = New Rectangle(0, 0, newWidth, newHeight)
thumbGraph.DrawImage(image, imageRectangle)
thumbnailImg.Save(targetPath, image.RawFormat)
End Using
End Sub
IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
103 Points
796 Posts
reduce image file size without losing quality
Apr 19, 2020 08:56 AM|kengkit|LINK
hi guys.. the following url is my reference site:
https://www.aspdotnet-suresh.com/2011/05/how-to-resize-size-image-without-losing.html
I having an issue while converting to vb using https://converter.telerik.com/
Error Message: Type of 'image' cannot be inferred from an expression containing 'image'
All-Star
160090 Points
13198 Posts
ASPInsiders
Moderator
Re: reduce image file size without losing quality
Apr 19, 2020 10:54 AM|mbanavige|LINK
I can't see if you imported the Sytem.Drawing namespace. Could just fully qualify the name.
Contributor
3370 Points
1409 Posts
Re: reduce image file size without losing quality
Apr 20, 2020 02:03 AM|samwu|LINK
Hi kengkit,
As mbanavige said, you should fully qualify the name.
The C # code in the link you provided is problematic, It should be the following code, and then you will convert it to vb code.
More information about Image.FromStream Method you can refer to this link:
https://docs.microsoft.com/en-us/dotnet/api/system.drawing.image.fromstream?view=netframework-4.8
Best regards,
Sam