img tag displays wrong orientation

前端 未结 14 1411
夕颜
夕颜 2020-11-27 12:11

I have an image at this link: http://d38daqc8ucuvuv.cloudfront.net/avatars/216/2014-02-19%2017.13.48.jpg

As you can see, this is a normal image with correct orientat

14条回答
  •  有刺的猬
    2020-11-27 13:15

    This problem was driving me crazy too. I was using PHP on my server side so I was not able to use @The Lazy Log(ruby) & @deweydb(python) solutions. However it pointed me to the right direction. I fixed it on the backed using Imagick's getImageOrientation().

    getImageOrientation(); 
    
        switch($orientation) { 
            case imagick::ORIENTATION_BOTTOMRIGHT: 
                $image->rotateimage("#000", 180); // rotate 180 degrees 
            break; 
    
            case imagick::ORIENTATION_RIGHTTOP: 
                $image->rotateimage("#000", 90); // rotate 90 degrees CW 
            break; 
    
            case imagick::ORIENTATION_LEFTBOTTOM: 
                $image->rotateimage("#000", -90); // rotate 90 degrees CCW 
            break; 
        } 
    
        // Now that it's auto-rotated, make sure the EXIF data is correct in case the EXIF gets saved with the image! 
        $image->setImageOrientation(imagick::ORIENTATION_TOPLEFT); 
    } 
    ?> 
    

    Here is the link if you want to read more. http://php.net/manual/en/imagick.getimageorientation.php

提交回复
热议问题