hi
i have a windows form . users can send their images , from that.
but i want to chek the size and type of that files to be in appropriate formats.
for ex. they should be able to send only .jpg files , with a defined sizes, and not else.
how can i do that
thank u

how to get the size and type of images?
Ryan0788
i wrote in vb and i wanted to convert your example to vb.
but i don't know how to convert this :
using (Image img = new Image(imageFile))
i tried :
imports(dim img as new image(imagefile))
but it's not true
VCPPUser
using System.Drawing;
public bool IsValidFormat ( string imageFile )
{
using (Image img = new Image(imageFile))
{
//Validate resolution (ensure it is 1024x768)
if ((img.Width != 1024) || (img.Height != 768))
return false;
//Validate format (ensure it is a jpeg)
if (img.RawFormat != ImageFormat.Jpeg)
return false;
//Must be valid
return true;
};
}
This function verifies the file is a jpeg of 1024x768 size. Of course I would recommend that if the file isn't a proper format that you simply modify it to be valid and then send it. You could prompt the user first. Of course your requirements might not be this flexible but users may get annoyed if they have to open the image in Paint just to resize and resave it.
Michael Taylor - 10/30/05
Adam_C
would u please give me some refrences
i don know how to use Image class
mcarr
Size - Size of image in pixels.
RawFormat - Will be ImageFormat.Jpeg for JPEG.
Image doesn't work with all image files so you'll want to wrap it in an exception handler. You also need to make sure you dispose of the Image object otherwise you'll leak memory and the file will remain locked.
Michael Taylor - 10/24/05
Roman Hnatiuk
would u please give me some references
i don know how to use Image class