ionic-team / capacitor-plugins

Official plugins for Capacitor ⚑️
533 stars 599 forks source link

[Bug]: Wrong iOS photo exif data #2209

Open sakonn opened 1 month ago

sakonn commented 1 month ago

Capacitor Version

πŸ’Š Capacitor Doctor πŸ’Š

Latest Dependencies:

@capacitor/cli: 6.1.2 @capacitor/core: 6.1.2 @capacitor/android: 6.1.2 @capacitor/ios: 6.1.2

Installed Dependencies:

@capacitor/cli: 6.1.2 @capacitor/core: 5.5.1 @capacitor/android: 5.5.1 @capacitor/ios: 5.5.1

[success] iOS looking great! πŸ‘Œ [success] Android looking great! πŸ‘Œ

Other API Details

npm version: 10.8.2
node version: v20.17.0
pod version: 1.13.0
iOS version: 17.4.1
ios device: iPhone SE 2nd generation

Platforms Affected

Current Behavior

I am developing a data collection app where data is collected primarily in the form of photos which are later processed. To make postprocessing more straightforward it is required that they are taken in portrait mode (not in landscape). So, I am trying to figure out a way to restrict taking pictures which are landscape-oriented. I have not found any suitable setting for that, so now I am trying to disable saving photos that are wider than higher (landscape by this logic) based on the photo metadata. Photos are taken by the capacitor camera plugin when taking the photos I have found out that information about the photos taken in the iOS app is incorrect.

Portrait photo taken in the ios app: 20241009-080808_4780201379629_overviewImage

And the related exif metadata about this photo which are returned by the plugin:

{
    "Flash": 16,
    "SubsecTimeOriginal": "675",
    "PixelXDimension": 4032,
    "MeteringMode": 5,
    "ApertureValue": 1.6959938131099002,
    "BrightnessValue": -3.0617721648310905,
    "ColorSpace": 65535,
    "FocalLenIn35mmFilm": 28,
    "SceneType": 1,
    "ExposureBiasValue": 0,
    "PixelYDimension": 3024,
    "Orientation": 1,
    "ExposureTime": 0.06666666666666667,
    "CompositeImage": 2,
    "ExposureProgram": 2,
    "WhiteBalance": 0,
    "ShutterSpeedValue": 3.9085506496196545,
    "LensModel": "iPhone SE (2nd generation) back camera 3.99mm f/1.8",
    "ExifVersion": "0232",
    "ISOSpeedRatings": [
      800
    ],
    "LensSpecification": [
      3.99,
      3.99,
      1.8,
      1.8
    ],
    "LensMake": "Apple",
    "SensingMethod": 2,
    "DateTimeDigitized": "2024:10:09 08:08:04",
    "ExposureMode": 0,
    "FNumber": 1.8,
    "DateTimeOriginal": "2024:10:09 08:08:04",
    "FocalLength": 3.99,
    "SubsecTimeDigitized": "675",
    "OffsetTimeOriginal": "+02:00",
    "SubjectArea": [
      2013,
      1511,
      2116,
      1330
    ],
    "OffsetTimeDigitized": "+02:00",
    "OffsetTime": "+02:00"
  },

Landscape photo taken in the ios app: 20241009-080905_4780201379629_facingImage

And the related exif metadata about this photo which are returned by the plugin:

{
    "Flash": 16,
    "SubsecTimeOriginal": "524",
    "PixelXDimension": 4032,
    "MeteringMode": 5,
    "ApertureValue": 1.6959938131099002,
    "BrightnessValue": -3.343055762488874,
    "ColorSpace": 65535,
    "FocalLenIn35mmFilm": 28,
    "SceneType": 1,
    "ExposureBiasValue": 0,
    "PixelYDimension": 3024,
    "Orientation": 1,
    "ExposureTime": 0.06666666666666667,
    "CompositeImage": 2,
    "ExposureProgram": 2,
    "WhiteBalance": 0,
    "ShutterSpeedValue": 3.9085506496196545,
    "LensModel": "iPhone SE (2nd generation) back camera 3.99mm f/1.8",
    "ExifVersion": "0232",
    "ISOSpeedRatings": [
      1250
    ],
    "LensSpecification": [
      3.99,
      3.99,
      1.8,
      1.8
    ],
    "LensMake": "Apple",
    "SensingMethod": 2,
    "DateTimeDigitized": "2024:10:09 08:09:01",
    "ExposureMode": 0,
    "FNumber": 1.8,
    "DateTimeOriginal": "2024:10:09 08:09:01",
    "FocalLength": 3.99,
    "SubsecTimeDigitized": "524",
    "OffsetTimeOriginal": "+02:00",
    "SubjectArea": [
      2013,
      1511,
      2116,
      1330
    ],
    "OffsetTimeDigitized": "+02:00",
    "OffsetTime": "+02:00"
  }

In my code, I am trying to compare PixelXDimension and PixelYDimension from the metadata and calculate if the photo is landscape or portrait. The problem is that these values are the same for both photos although they have different orientations.

On the contrary, the same photos taken with the android app return the expected result. Landscape photo metadata from an android app:

    "Orientation": "0",
    "PixelXDimension": "4624",
    "PixelYDimension": "3472",

Portrait photo metadata from an android app:

    "Orientation": "0",
    "PixelXDimension": "3472",
    "PixelYDimension": "4624",

Expected Behavior

I expect to get proper photo dimensions based on the photo orientation. So if the photo is taken landscape I expect to get the XDimension wider then the YDimension. And if the photo is taken as a portrait than the YDimension should be bigger than XDimension.

Project Reproduction

https://github.com/sakonn/probable-octo-invention

Additional Information

No response

eric-horodyski commented 1 month ago

This issue relates to Camera functionality, which is part of @capacitor/camera, and as such as been transferred to the appropriate repository.