LoginSignup
2
0

More than 5 years have passed since last update.

画像の Orientation を補正して表示してくれる loadImage がIE11で動かなかった

Last updated at Posted at 2018-07-25

画像の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 });
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0