<input id="file" type="file" />
<img id="preview" />
<script>
const preview = document.getElementById("preview");
const input = document.getElementById("file");
input.addEventListener("change", (event) => {
const file = event.target.files[0];
imageFileToOrientationFixedDataURL(file).then((url) => {
preview.src = url; // data:image/png;base64,iVBORw0K...
});
});
</script>
If an unsupported format is received, it returns dataURL without processing.
npm install --save @mish-tv/fix-image-orientation