iOS 6 Safari图像上传 – 方向错误

我已经建立了一个网络应用程序,可以让您从浏览器上传照片.当在iOS 6中使用此功能时,即使在上传时拍摄照片,照片似乎也以横向显示.我应该做一些服务器端检查,以使图像正确的方式,还是有某种iOS特定属性/ JavaScript我可以应用于上传表单来解决这个问题?

更新

根据要求,这里是我写的代码.先决条件是我使用PHP和WideImage库(这是一个更大的脚本的代码段,所以如果你喜欢,你可以使用不同的图像处理方法).

// Load Image Into Wide Image
$image=WideImage::load(IMG_UPLOAD_DIR.$result['name']);
$exif=exif_read_data(IMG_UPLOAD_DIR.$result['name']);
$orientation=$exif['Orientation'];
$result['orientation']=$orientation;

// Use Wide Image To Resize Images
$full=$image->resize(IMG_FULL_H,IMG_FULL_H);
$thumb=$image->resize(IMG_THUMB_W,IMG_THUMB_H);

switch($orientation){
    case 2:
        $full->mirror()->savetoFile(IMG_UPLOAD_DIR.$result['name'],90);
        $thumb->mirror()->savetoFile(IMG_UPLOAD_DIR.$thumbName,90);
        break;

    case 3:
        $full->rotate(-180)->savetoFile(IMG_UPLOAD_DIR.$result['name'],90);
        $thumb->rotate(-180)->savetoFile(IMG_UPLOAD_DIR.$thumbName,90);
        break;

    case 4:
        $full->rotate(180)->mirror()->savetoFile(IMG_UPLOAD_DIR.$result['name'],90);
        $thumb->rotate(180)->mirror()->savetoFile(IMG_UPLOAD_DIR.$thumbName,90);
        break;

    case 5:
        $full->rotate(90)->mirror()->savetoFile(IMG_UPLOAD_DIR.$result['name'],90);
        $thumb->rotate(90)->mirror()->savetoFile(IMG_UPLOAD_DIR.$thumbName,90);
        break;

    case 6:
        $full->rotate(90)->savetoFile(IMG_UPLOAD_DIR.$result['name'],90);
        $thumb->rotate(90)->savetoFile(IMG_UPLOAD_DIR.$thumbName,90);
        break;

    case 7:
        $full->rotate(-90)->savetoFile(IMG_UPLOAD_DIR.$result['name'],90);
        $thumb->rotate(-90)->savetoFile(IMG_UPLOAD_DIR.$thumbName,90);
        break;

    case 8:
        $full->rotate(-90)->savetoFile(IMG_UPLOAD_DIR.$result['name'],90);
        break;

    default:
        $full->savetoFile(IMG_UPLOAD_DIR.$result['name'],90);
        $thumb->savetoFile(IMG_UPLOAD_DIR.$thumbName,90);
        break;
}

解决方法

检查图像exif元数据,iPhone相机拍摄“旋转”图像.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...