rotation-css

Returns the css needed to rotate an image based on it's exif data

Usage no npm install needed!

<script type="module">
  import rotationCss from 'https://cdn.skypack.dev/rotation-css';
</script>

README

RotationCSS

This npm package parses the exif data of a jpeg file and returns a hash that has the necessary CSS to rotate the image correctly.

  import rotationCSS from 'rotation-css';

  const inputElement = document.querySelector("input")
  const imageElement = document.querySelector("img")

  const reader = new FileReader();
  reader.onload = function(event) {
    imageElement.src = event.target.result;
    imageElement.style = rotationCSS(event.target.result);
  };
  reader.readAsDataURL(inputElement.files[0]);

This package uses code based on Exif.js to extract the actual metadata.