【问题标题】:Ipad photos not rotated when uploaded to a website directly from iPad but ok when uploaded from the computer直接从 iPad 上传到网站时,iPad 照片没有旋转,但从计算机上传时可以
【发布时间】:2012-11-10 16:07:03
【问题描述】:

我正在开发一个 PHP 网站,当我上传从 ipad 以纵向模式拍摄的照片时,它会在网站上以横向显示,但是当我从计算机上传相同的照片时(对照片)它在横向模式下正确显示。所有横向照片都可以横向显示。

我试图找到解决此问题的方法,并阅读了有关从 EXIF 数据获取方向的信息,但无论照片是否已拍摄,“方向”标签实际上总是相同的(如果我没记错的话是 1)横向或纵向。

我尝试从 ipad 将肖像照片上传到 flickr,并且它在肖像模式下正确显示,所以我错过了什么?

谢谢。

【问题讨论】:

    标签: php ipad orientation exif


    【解决方案1】:

    取自http://www.php.net/manual/en/function.exif-read-data.php#110894 来源:gmail dot com 的 chadsmith729。

    我自己没有测试过这个解决方案..

    <?php
    $image = imagecreatefromstring(file_get_contents($_FILES['image_upload']['tmp_name']));
    $exif = exif_read_data($_FILES['image_upload']['tmp_name']);
    if(!empty($exif['Orientation'])) {
        switch($exif['Orientation']) {
            case 8:
                $image = imagerotate($image,90,0);
                break;
            case 3:
                $image = imagerotate($image,180,0);
                break;
            case 6:
                $image = imagerotate($image,-90,0);
                break;
        }
    }
    // $image now contains a resource with the image oriented correctly
    ?>
    

    这应该适用于所有 Apple 产品(iPod、iPhone 和 iPad)

    【讨论】:

    • 如果给出未经测试的解决方案作为答案。这基本上是说你不知道它是否有效。另外,我希望 Chad 不介意您公开发布他的电子邮件
    • 像魅力一样工作。不得不将 90 换成 -90,反之亦然。
    猜你喜欢
    • 2013-04-02
    • 1970-01-01
    • 1970-01-01
    • 2016-07-09
    • 1970-01-01
    • 2012-05-26
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多