canuckconsulting
asked on
Determine size of image in memory
I have a .Net 4 Windows Forms project created with Visual Studio 2010 using c#.
I need to open an image file (jpg or gif) and resize the dimensions to a fixed size and then adjust the quality of the image until the image size is 30kb or less. Is there a way to calculate the memory used by this image while in memory? I don't want the overhead of saving it to disk to check System.IO.FileInfo. I would be happy to use a free library or utility which would help.
Scott
I need to open an image file (jpg or gif) and resize the dimensions to a fixed size and then adjust the quality of the image until the image size is 30kb or less. Is there a way to calculate the memory used by this image while in memory? I don't want the overhead of saving it to disk to check System.IO.FileInfo. I would be happy to use a free library or utility which would help.
Scott
I forgot to mention that you will require these namespaces:
System.Drawing
System.Drawing.Imaging
System.Drawing
System.Drawing.Imaging
ASKER
This is perfect; thanks! Can you advis if it is possible to convert the contents of ms back into an Image? I would like the method to return the reduced image which will be saved later on?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect...thank you!
Glad to help!
Open in new window