画像の Orientation を補正して表示してくれる loadImage がIE11で動かなかった
2748 ワード
画像のEXIF情報を読んで補正してくれるライブラリ https://github.com/blueimp/JavaScript-Load-Image を使っていて、IE11でOrientationの向きが反映されなかったのでメモ。
原因は loadImage
にURLを渡していたからだった。IE11の場合URLを渡すと画像のメタ情報を取れないみたい。
If the file is given as URL and the browser supports the fetch API, fetches the file as Blob to be able to parse the meta data.
README.md に書いてあった。 fetch APIに対応していないブラウザはURLで渡すとメタ情報を作れない。
example.js
// URL
loadImage('http://example.org/some-image.png', function(img, data){
// IE11だとundefined
console.log(data.exif);
}, { orientation: true });
// blob
loadImage(document.querySelector('input[type=file]').files[0], function(img, data){
console.log(data.exif); // 何か出る
}, { orientation: true });
Author And Source
この問題について(画像の Orientation を補正して表示してくれる loadImage がIE11で動かなかった), 我々は、より多くの情報をここで見つけました https://qiita.com/oieioi/items/c0b10cd41f6b9662f3f1著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .