numandev1 / react-native-compressor

🗜️Compress Image, Video, and Audio same like Whatsapp 🚀✨
MIT License
949 stars 93 forks source link

getImageMetaData width/height does not respect orientation on iOS #285

Open terrysahaidak opened 7 months ago

terrysahaidak commented 7 months ago

Current behavior

When we get image metadata, it returns us imageWidth and imageHeight, but when we pick that image, the image picker returns flipped values. Since imageWidth and imageHeight are actually "default" orientation values. These values are matching the exif values where we have orientation.

Here is an example object:

{"ImageHeight": 3024, "ImageWidth": 4032, "Orientation": 6, "exif": {"ColorModel": "RGB", "DPIHeight": 72, "DPIWidth": 72, "Depth": 8, "Orientation": 6, "PixelHeight": 3024, "PixelWidth": 4032, "ProfileName": "Display P3", "extension": "jpg", "size": 387221, "{Exif}": {"ColorSpace": 65535, "PixelXDimension": 4032, "PixelYDimension": 3024}, "{JFIF}": {"DensityUnit": 0, "JFIFVersion": [Array], "XDensity": 72, "YDensity": 72}, "{TIFF}": {"Orientation": 6, "ResolutionUnit": 2, "XResolution": 72, "YResolution": 72}}, "extension": "jpg", "size": 387221}

And what picker returned me:

{"height": 4032, "width": 3024}

Expected behavior

I would assume that imageWidth and imageHeight would respect the orientation and would show the same values as image picker does, but the exif values should be the original values and the orientation if you really need it.

Platform

React Native Version

0.72.9

React Native Compressor Version

1.8.24

Reproducible Steps And Demo

github-actions[bot] commented 7 months ago

👋 @terrysahaidak Thanks for opening your issue here! If you find this package useful hit the star🌟!

terrysahaidak commented 7 months ago

This seems to be true also for the getVideoMetaData but it does not have the orientation, here is an example response:


{"creationDate": "2024-04-02T20:49:56+0300", "duration": 3.0016666666666665, "extension": "mov", "height": 2160, "location": "", "size": 17938656, "width": 3840}