Last active
August 14, 2021 09:08
-
-
Save kdssoftware/70db6a140728bda5fdf0588344ec48f7 to your computer and use it in GitHub Desktop.
Jimp autorotate using Exif tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let autoRotate = async (JimpImage) =>{ | |
switch(JimpImage._exif.tags?.Orientation||1){ | |
case 2: | |
await JimpImage.flip(true,false); | |
break; | |
case 3: | |
await JimpImage.rotate(180); | |
break; | |
case 4: | |
await JimpImage.rotate(180).flip(true,false); | |
break; | |
case 5: | |
await JimpImage.rotate(-90).flip(true,false); | |
break; | |
case 6: | |
await JimpImage.rotate(90); | |
break; | |
case 7: | |
await JimpImage.rotate(-90).flip(true,false); | |
break; | |
case 8: | |
await JimpImage.rotate(-90); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More info at sirv.com