Skip to content

Instantly share code, notes, and snippets.

@Dexdot
Created December 28, 2020 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dexdot/b745ae7a9bc64cecf88adbd96713c5bd to your computer and use it in GitHub Desktop.
Save Dexdot/b745ae7a9bc64cecf88adbd96713c5bd to your computer and use it in GitHub Desktop.
export async function getImageUrl(file: File): Promise<string | ArrayBuffer> {
return new Promise((resolve) => {
import('exif-js')
.then((EXIF) => {
EXIF.getData(file, function onGetData() {
const reader = new FileReader();
reader.onload = ({ target }) => {
resolve(target.result);
};
reader.readAsDataURL(this);
});
})
.catch((e) => {
console.error(e);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment