Skip to content

Instantly share code, notes, and snippets.

@kdssoftware
Last active August 14, 2021 09:08
Show Gist options
  • Save kdssoftware/70db6a140728bda5fdf0588344ec48f7 to your computer and use it in GitHub Desktop.
Save kdssoftware/70db6a140728bda5fdf0588344ec48f7 to your computer and use it in GitHub Desktop.
Jimp autorotate using Exif tags
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;
}
}
@kdssoftware
Copy link
Author

kdssoftware commented Aug 10, 2021

image
More info at sirv.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment