img tag displays wrong orientation

前端 未结 14 1503
夕颜
夕颜 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:12

    You can use Exif-JS , to check the "Orientation" property of the image. Then apply a css transform as needed.

    EXIF.getData(imageElement, function() {
                    var orientation = EXIF.getTag(this, "Orientation");
    
                    if(orientation == 6)
                        $(imageElement).css('transform', 'rotate(90deg)')
    });  
    

提交回复
热议问题