- private void ProcessFile(FileInfo fi)
- {
- Bitmap bmp = new Bitmap(fi.FullName);
- EXIFextractor exif = new EXIFextractor(ref bmp, "\n");
- if (exif["Orientation"] != null)
- {
- string orientation = exif["Orientation"].ToString();
- RotateFlipType rotateFlipType = OrientationToFlipType(orientation);
- if (rotateFlipType != RotateFlipType.RotateNoneFlipNone)
- {
- //rotate the image
- bmp.RotateFlip(rotateFlipType);
- if (chkUpdateOrientationProperty.Checked)
- {
- try
- {
- //reset the orientation flag
- exif.SetOrientationTag(1);
- }
- catch { }
- }
- //save the image
- string newFileName = (chkRotateOriginals.Checked) ? fi.FullName : SaveAsFileName(fi);
- bmp.Save(newFileName, ImageFormat.Jpeg);
- }
- }
- else
- {
- }
- bmp.Dispose();
- }
If I comment out the line
the image size is not affected, so I've narrowed down the problem to that one line of code. I've checked the properties of the original and rotated images and the dimensions aren't any smaller (just rotated), dpi, bit depth, etc are all the same. So I'm at a loss as to why the rotated image's file size is so much smaller. Does anyone have any idea what would cause this and if there is a way to prevent this from happening? Thanks in advance.bmp.RotateFlip( rotateFlipType );
Replies
Know the answer? Post it — somebody with the same question will find it here.