Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every one.
I need to reduce image width and height (sometimes just 10px even), but when i do it, the physical size increase 2 or even 3 times!
I try 2 method
C#
var newImage = new Bitmap(newWidth, newHeight);
Graphics.FromImage(newImage).DrawImage(image, 0, 0, newWidth, newHeight);


And
C#
var newImage = image.GetThumbnailImage(newWidth, newHeight, null, IntPtr.Zero);


Both of them increase physical image. coz sometimes i reduce width 10px, coz i need all photos in 500px width, and people upload images for example in 510px width.
in this situation increasing physical size is more.

Any suggestion please?
Thanks in advance.
Posted
Comments
lukeer 5-Aug-13 4:39am    
What exactly do you call "physical size"?

Is ist the file size in bytes?
Or the size of a photo when printed in cm/inch?
arminamini 5-Aug-13 6:06am    
I mean file size, bytes.

1 solution

Check what image format type you are saving as - BMP for example has a bigger footprint than jpg. Also check the resolution you are saving at. Both of these factors affect physical file size.

Look here:

http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.save.aspx[^]

and here


[^]
 
Share this answer
 
Comments
arminamini 5-Aug-13 6:06am    
Thank u very much. it works!
DataBytzAI 5-Aug-13 7:27am    
welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900