Accessing JPEG EXIF rotation data in JavaScript on the client side

前端 未结 8 1448
臣服心动
臣服心动 2020-11-22 13:53

I\'d like to rotate photos based on their original rotation, as set by the camera in JPEG EXIF image data. The trick is that all this should happen in the browser, using Jav

8条回答
  •  无人及你
    2020-11-22 14:28

    If you want it cross-browser, your best bet is to do it on the server. You could have an API that takes a file URL and returns you the EXIF data; PHP has a module for that.

    This could be done using Ajax so it would be seamless to the user. If you don't care about cross-browser compatibility, and can rely on HTML5 file functionality, look into the library JsJPEGmeta that will allow you to get that data in native JavaScript.

提交回复
热议问题