遇到這種問題 有點傻眼
不知道怎麼解決,測了也沒發現什麼規律性的原因(偏偏我就是拿偏偏我就是用iphone safari)
頓時有了希望全世界都生活在智障型手機的時代是多麼美好,多麼幸福,多麼......方便 ORZ
不過感嘆歸感嘆,希望歸希望,身為21世紀現代人類,還是要追求一下科技進步、社會發展
不用你們提醒我,我知道我現在很難得的正在囉嗦.............
[問題原因] 貌似是瀏覽器吃不到照片的一些tag
這裡有針對IOS詳細介紹照片方向的問題
解決之前 還要加入參考
點我連結下載頁面 進去之後點 Donload Source files
code在這
方便大家 也為了防止頁面被404狙擊 我還是備份一下
- HttpPostedFile file = HttpContext.Current.Request.Files["file"];
- //Create bitmap image from posted file
- System.Drawing.Bitmap bmpImg = new System.Drawing.Bitmap(file.InputStream);
- //rotate if needed
- bmpImg = rotateImage(bmpImg);
- //save image
- targetFilePath = "somewhere...";
- bmpImg.Save(targetFilePath, ImageFormat.Jpeg);
- public Bitmap rotateImage(System.Drawing.Bitmap img)
- {
- try
- {
- RotateFlipType rft = RotateFlipType.RotateNoneFlipNone;
- System.Drawing.Imaging.PropertyItem[] properties = img.PropertyItems;
- foreach (System.Drawing.Imaging.PropertyItem p in properties)
- {
- if (p.Id == 274 || p.Id == 5029)
- {
- short orientation = BitConverter.ToInt16(p.Value, 0);
- switch (orientation)
- {
- case 1:
- rft = RotateFlipType.RotateNoneFlipNone;
- break;
- case 3:
- rft = RotateFlipType.Rotate180FlipNone;
- break;
- case 6:
- rft = RotateFlipType.Rotate90FlipNone;
- break;
- case 8:
- rft = RotateFlipType.Rotate270FlipNone;
- break;
- }
- }
- }
- if (rft != RotateFlipType.RotateNoneFlipNone)
- {
- img.RotateFlip(rft);
- }
- }
- catch
- {
- }
- return img;
- }
沒有留言:
張貼留言