Hi all,
I used "NoCoolHandle"'s code from this thread ...
which does work, but can anyone tell me why the thumbnails being made are around five time bigger (in file size) than the original, it's VERY odd!.
test.jpg 640x480 - 38KB
test_thumb.jpg 320x240 - 168KB
function..
Am I doing something wrong ?, is there a better way to keep some quality and get a smaller file size ?...
Any ideas would be great, thanks.
I used "NoCoolHandle"'s code from this thread ...
which does work, but can anyone tell me why the thumbnails being made are around five time bigger (in file size) than the original, it's VERY odd!.
test.jpg 640x480 - 38KB
test_thumb.jpg 320x240 - 168KB
Code:
'Create Thumbnail
Dim thumbnail As System.Drawing.Image
Dim image As System.Drawing.Image = System.Drawing.Image.FromFile(path)
thumbnail = ScaleImage(image, 320, 240)
thumbnail.Save(Server.MapPath(AppPath & "/Images/Thumbs/" & imgName & "_thumb.jpg"))
function..
Code:
Function ScaleImage(ByVal imgFull As Image, ByVal intX As Integer, ByVal intY As Integer) As Image
Dim dblScaleFactor As Double
Dim dblScaleX, dblScaleY As Double
dblScaleX = intX / imgFull.Width
dblScaleY = intY / imgFull.Height
If dblScaleX > dblScaleY Then
dblScaleFactor = dblScaleX
Else
dblScaleFactor = dblScaleY
End If
Dim scale_factor As Single = CType(dblScaleFactor, Single)
Dim imgBMP_dest As New Bitmap(CInt(imgFull.Width * scale_factor), CInt(imgFull.Height * scale_factor))
Dim imgOutput As Graphics = Graphics.FromImage(imgBMP_dest)
imgOutput.DrawImage(imgFull, 0, 0, imgBMP_dest.Width + 1, imgBMP_dest.Height + 1)
imgOutput.Dispose()
imgOutput = Nothing
Return imgBMP_dest
End Function
Am I doing something wrong ?, is there a better way to keep some quality and get a smaller file size ?...
Any ideas would be great, thanks.