Click here to Skip to main content
15,891,902 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
follow the below link and you can find the below code in that.

Resizing image dynamically using C#[^]
{
Bitmap imgIn = new Bitmap(path);--------------->It is throughing an error like parameter is not valid.

double y = imgIn.Height;
double x = imgIn.Width;

double factor = 1;
if (width > 0)
{


TIA

What I have tried:

i have tryed to compress the photo

for example: one photo having 1MB before uploading then it have to be compress into KB
Posted
Updated 12-Sep-16 19:05pm
v2
Comments
David_Wimbley 12-Sep-16 9:34am    
Just shrink it till its the size you want? Is that what you want to know?
Member 12735242 13-Sep-16 1:07am    
I need some more clarity

That's not a very good article or technique IMO. You need to ensure the "path" is the physical location of the file on the server's file system. If you look at the bottom of the article there is a description of how to use the link. As we don't know how you are calling your code we can't really say what the problem is, but as I said "path" needs to refer to an image on the server's file system.
 
Share this answer
 
Quote:
How to compress a photo from mb to kb

Short answer: you can't. Compression is not infinite.

The only practical way is to make thumbnails (small pictures)
You need to reduce the picture size by reducing the number of pixels Height and Width.
Image scaling - Wikipedia, the free encyclopedia[^]
 
Share this answer
 

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