I am trying to reduce employee picture before uploading. checked for help but the all the answers are very much confusing. And I am here to ask help from experts :)
I am opening image to my picture box through below code
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "JPG Files(*.jpg)|*.jpg|GIF Files(*.gif)|*.gif|All Files(*.*)|*.*";
dlg.Title = "Select Employee Picture";
if (dlg.ShowDialog() == DialogResult.OK)
{
Image im = new Bitmap(dlg.FileName);
picEMP.Image = im;
string imgloc = dlg.FileName.ToString();
}
and making the image to binary with below codes
byte[] img = null;
FileStream fs = new FileStream(imgloc, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
img = br.ReadBytes((int)fs.Length);
and finally uploading with a parameter value
command.Parameters.Add(new SqlParameter("@img", img));
But I am not checking image size. I want to check the image size or the resolution(height, width) and reducing image size with a fix size like (188,222) and then upload image to my sql server. My SQL connection code is below:
SqlConnection conn = new SqlConnection("Data Source=host; Initial Catalog=TimeAttendance; User ID=id; Password=password");
Please Help .......