G'Day mate.
Im not to sure if Im reading your code right but
ResizeAndSaveToAll = ResizedImg.Size.ToString is not nessesarly the
size of your new file.
Anyways Im probably on the wrong track there.
Now a 500x550 bitmap image @ 8bpp would ocupy about 275kb of data.
That your orignial image was only 42k suggests it was using rle
compression (google this if your not to sure what Im yapping about).
Your new image lets see 400x440 = 176,000 bytes theres your 176kb. So
its safe to assume that your second image does not use rle compression
hence your discrepency.
Anyways you can set the compression trivialy. But let me point out
something.
The bmp format is generaly not suitable for thumbnails. _especialy_
for web use.
What you must consider is two points:
1st the resampling performed on bitmaps can degrade the rle
compressability of and image if the resize is small (as in your case).
This happens in many ways but maily because pixels are blended
together and the length of consequative identical pixel sequences is
reduced. This can also cause your image to grow even after you fix
your rle problems. The bmp picture tubnails will only achive modest
savings until you reach 50%(rough number) or greater size reduction.
2nd the jpeg format with compression set to the 30% range (ie very
lossy) performs well for tumbnail sized images around 64x64. This is a
much better thumnail solution as file sizes are _extremly_ small and
with the small size of the image visual aritfacts are less noticable.
(If you don't belve me on this try it and the results will speek for
them selves).
-dm
For example my original file would be a bitmap with
Quote:
500 X 550 px dimensions and a file size of 42.5KB...my resized image would be
a bitmap with 400 X 440 px dimensions and a file size of 171KB.
'manipulate image
Dim Img As Image = Image.FromFile(vTempDir & "/" & pDir)
Dim dummyCallBack As Image.GetThumbnailImageAbort
dummyCallBack = New Image.GetThumbnailImageAbort(AddressOf
DummyFunction)
Dim vImgSize As String = Img.Size.ToString
vImgSize = vImgSize.Replace("{", "")
vImgSize = vImgSize.Replace("}", "")
Dim newImgSize As String = Rescale(vImgSize, pWidth)
Dim vTemp() As String = newImgSize.Split(";")
Dim vNewWidth As String = vTemp(0)
Dim vNewHeight As String = vTemp(1)
'create & save resized image
Dim ResizedImg As Image = Img.GetThumbnailImage(vNewWidth,
vNewHeight, dummyCallBack, IntPtr.Zero)
ResizedImg.Save(vSaveNewImgDir & "/" & pDir)
ResizeAndSaveToAll = ResizedImg.Size.ToString
End Function |