fengyuanchen / compressorjs

JavaScript image compressor.
https://fengyuanchen.github.io/compressorjs/
MIT License
5.23k stars 439 forks source link

Question: Is there a way to check if an image is portrait or landscape? #176

Closed MatthewLHolden closed 1 year ago

MatthewLHolden commented 1 year ago

Firstly, thanks for a great product. It's my go to for projects :)

I have a scenario whereby when uploading a resized image to a database, I would like to include whether the image is portrait or landscape. Does the package expose that information so that I can add it to my database?

Thanks!

fengyuanchen commented 1 year ago

Just load the image into an <img> element or the new Image() constructor, and check its naturalWidth and naturalHeight directly.