JS Client-Side Exif Orientation: Rotate and Mirror JPEG Images

前端 未结 12 1117
花落未央
花落未央 2020-11-22 11:59

Digital camera photos are often saved as JPEG with an EXIF \"orientation\" tag. To display correctly, images need to be rotated/mirrored depending on which orientation is se

12条回答
  •  星月不相逢
    2020-11-22 12:34

    I created a class wrapped in an ES6 module that solves exactly this.

    It's 103 lines, no dependencies, and fairly nicely structured and documented, meant to be easy to modify/reuse.

    Handles all 8 possible orientations, and is Promise-based.

    Here you go, hope this still helps someone: https://gist.github.com/vdavid/3f9b66b60f52204317a4cc0e77097913

提交回复
热议问题