expo-image-picker 14.1.1 → 14.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,19 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 14.2.0 — 2023-05-08
14
+
15
+ ### 🎉 New features
16
+
17
+ - Added ability to choose the camera-facing type. ([#22143](https://github.com/expo/expo/pull/22143) by [@YoussefHenna](https://github.com/YoussefHenna))
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - Fix images unexpectedly being converted to `.png` when opening `.bmp` files and selecting any quality in `ImagePickerOptions`. ([#21361](https://github.com/expo/expo/pull/21361) by [@behenate](https://github.com/behenate))
22
+ - Fix issue where the array of permissions could end up empty causing an exception. ([#21589](https://github.com/expo/expo/pull/21589) by [@alanhughes](https://github.com/alanjhughes))
23
+ - Fix rotated videos returning incorrect width/height. [#12573](https://github.com/expo/expo/issues/12573) ([#21758](https://github.com/expo/expo/pull/21758) by [@mmmulani](https://github.com/mmmulani))
24
+ - Fix NullPointerException for launchCameraAsync on Android 13. ([#22123](https://github.com/expo/expo/pull/22123) by [@witheroux](https://github.com/witheroux))
25
+
13
26
  ## 14.1.1 — 2023-02-09
14
27
 
15
28
  ### ⚠️ Notices
package/README.md CHANGED
@@ -16,7 +16,7 @@ Provides access to the system's UI for selecting images and videos from the phon
16
16
 
17
17
  # Installation in managed Expo projects
18
18
 
19
- For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/imagepicker/).
19
+ For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/imagepicker/).
20
20
 
21
21
  # Installation in bare React Native projects
22
22
 
@@ -25,7 +25,7 @@ For bare React Native projects, you must ensure that you have [installed and con
25
25
  ### Add the package to your npm dependencies
26
26
 
27
27
  ```
28
- expo install expo-image-picker
28
+ npx expo install expo-image-picker
29
29
  ```
30
30
 
31
31
  ### Configure for iOS
@@ -62,7 +62,7 @@ This package automatically adds the `CAMERA`, `READ_EXTERNAL_STORAGE`, and `WRIT
62
62
 
63
63
  > This plugin is applied automatically in EAS Build, only add the config plugin if you want to pass in extra properties.
64
64
 
65
- After installing this npm package, add the [config plugin](https://docs.expo.io/guides/config-plugins/) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`:
65
+ After installing this npm package, add the [config plugin](https://docs.expo.dev/home/config-plugins/introduction) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`:
66
66
 
67
67
  ```json
68
68
  {
@@ -72,7 +72,7 @@ After installing this npm package, add the [config plugin](https://docs.expo.io/
72
72
  }
73
73
  ```
74
74
 
75
- Next, rebuild your app as described in the ["Adding custom native code"](https://docs.expo.io/workflow/customizing/) guide.
75
+ Next, rebuild your app as described in the ["Adding custom native code"](https://docs.expo.dev/workflow/customizing/) guide.
76
76
 
77
77
  ### API
78
78
 
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '14.1.1'
6
+ version = '14.2.0'
7
7
 
8
8
  buildscript {
9
9
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -74,7 +74,7 @@ android {
74
74
  minSdkVersion safeExtGet("minSdkVersion", 21)
75
75
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
76
76
  versionCode 22
77
- versionName "14.1.1"
77
+ versionName "14.2.0"
78
78
  }
79
79
  lintOptions {
80
80
  abortOnError false
@@ -176,8 +176,8 @@ class ImagePickerModule : Module() {
176
176
  private fun getMediaLibraryPermissions(writeOnly: Boolean): Array<String> =
177
177
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
178
178
  listOfNotNull(
179
- READ_MEDIA_IMAGES.takeIf { !writeOnly },
180
- READ_MEDIA_VIDEO.takeIf { !writeOnly }
179
+ READ_MEDIA_IMAGES,
180
+ READ_MEDIA_VIDEO
181
181
  ).toTypedArray()
182
182
  } else {
183
183
  listOfNotNull(
@@ -213,8 +213,10 @@ class ImagePickerModule : Module() {
213
213
  continuation.resumeWithException(UserRejectedPermissionsException())
214
214
  }
215
215
  },
216
- Manifest.permission.WRITE_EXTERNAL_STORAGE.takeIf { Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU },
217
- Manifest.permission.CAMERA
216
+ *listOfNotNull(
217
+ Manifest.permission.WRITE_EXTERNAL_STORAGE.takeIf { Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU },
218
+ Manifest.permission.CAMERA
219
+ ).toTypedArray()
218
220
  )
219
221
  }
220
222
 
@@ -37,6 +37,9 @@ internal class ImagePickerOptions : Record, Serializable {
37
37
  @Field
38
38
  var aspect: Pair<Int, Int>? = null
39
39
 
40
+ @Field
41
+ var cameraType: CameraType = CameraType.BACK
42
+
40
43
  fun toCameraContractOptions(uri: Uri) = CameraContractOptions(uri, this)
41
44
 
42
45
  fun toImageLibraryContractOptions() = ImageLibraryContractOptions(this)
@@ -78,3 +81,8 @@ internal enum class MediaTypes(val value: String) : Enumerable {
78
81
  const val AllMimeType = "*/*"
79
82
  }
80
83
  }
84
+
85
+ internal enum class CameraType(val value: String) : Enumerable {
86
+ BACK("back"),
87
+ FRONT("front"),
88
+ }
@@ -8,6 +8,7 @@ import android.net.Uri
8
8
  import android.provider.MediaStore
9
9
  import androidx.activity.result.contract.ActivityResultContract
10
10
  import expo.modules.imagepicker.ImagePickerOptions
11
+ import expo.modules.imagepicker.CameraType
11
12
  import expo.modules.imagepicker.toMediaType
12
13
  import expo.modules.kotlin.activityresult.AppContextActivityResultContract
13
14
  import expo.modules.kotlin.providers.AppContextProvider
@@ -34,6 +35,15 @@ internal class CameraContract(
34
35
  if (input.options.mediaTypes.toCameraIntentAction() == MediaStore.ACTION_VIDEO_CAPTURE) {
35
36
  putExtra(MediaStore.EXTRA_DURATION_LIMIT, input.options.videoMaxDuration)
36
37
  }
38
+ if (input.options.cameraType == CameraType.FRONT) {
39
+ putExtra("android.intent.extras.LENS_FACING_FRONT", 1)
40
+ putExtra("android.intent.extras.CAMERA_FACING", 1)
41
+ putExtra("android.intent.extra.USE_FRONT_CAMERA", true)
42
+ } else {
43
+ putExtra("android.intent.extras.LENS_FACING_BACK", 1)
44
+ putExtra("android.intent.extras.CAMERA_FACING", 0)
45
+ putExtra("android.intent.extra.USE_FRONT_CAMERA", false)
46
+ }
37
47
  }
38
48
 
39
49
  override fun parseResult(input: CameraContractOptions, resultCode: Int, intent: Intent?): ImagePickerContractResult =
@@ -162,6 +162,16 @@ export declare enum UIImagePickerPresentationStyle {
162
162
  */
163
163
  AUTOMATIC = "automatic"
164
164
  }
165
+ export declare enum CameraType {
166
+ /**
167
+ * Back/rear camera.
168
+ */
169
+ back = "back",
170
+ /**
171
+ * Front camera
172
+ */
173
+ front = "front"
174
+ }
165
175
  /**
166
176
  * @hidden
167
177
  * @deprecated Use `ImagePickerAsset` instead
@@ -294,8 +304,9 @@ export type ImagePickerOptions = {
294
304
  * Whether to show a UI to edit the image after it is picked. On Android the user can crop and
295
305
  * rotate the image and on iOS simply crop it.
296
306
  *
297
- * > Cropping multiple images is not supported - this option is mutually exclusive with `allowsMultipleSelection`.
298
- * > On iOS, this option is ignored if `allowsMultipleSelection` is enabled.
307
+ * > - Cropping multiple images is not supported - this option is mutually exclusive with `allowsMultipleSelection`.
308
+ * > - On iOS, this option is ignored if `allowsMultipleSelection` is enabled.
309
+ * > - On iOS cropping a `.bmp` image will convert it to `.png`.
299
310
  *
300
311
  * @default false
301
312
  * @platform ios
@@ -396,6 +407,15 @@ export type ImagePickerOptions = {
396
407
  * @platform ios
397
408
  */
398
409
  presentationStyle?: UIImagePickerPresentationStyle;
410
+ /**
411
+ * Selects the camera-facing type. The `CameraType` enum provides two options:
412
+ * `front` for the front-facing camera and `back` for the back-facing camera.
413
+ * - **On Android**, the behavior of this option may vary based on the camera app installed on the device.
414
+ * @default CameraType.back
415
+ * @platform ios
416
+ * @platform android
417
+ */
418
+ cameraType?: CameraType;
399
419
  };
400
420
  export type OpenFileBrowserOptions = {
401
421
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ImagePicker.types.d.ts","sourceRoot":"","sources":["../src/ImagePicker.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAG1D;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,kBAAkB,GAAG;IAChE;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC;CAC/C,CAAC;AAGF,oBAAY,gBAAgB;IAC1B;;OAEG;IACH,GAAG,QAAQ;IACX;;OAEG;IACH,MAAM,WAAW;IACjB;;OAEG;IACH,MAAM,WAAW;CAClB;AAGD,oBAAY,iBAAiB;IAC3B;;;;OAIG;IACH,WAAW,IAAI;IACf;;;;OAIG;IACH,UAAU,IAAI;IACd;;;;OAIG;IACH,aAAa,IAAI;IACjB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;;;OAIG;IACH,YAAY,IAAI;IAChB;;;;OAIG;IACH,YAAY,IAAI;IAChB;;;;OAIG;IACH,aAAa,IAAI;IACjB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;;;OAIG;IACH,cAAc,KAAK;CACpB;AAGD,oBAAY,kCAAkC;IAC5C;;OAEG;IACH,IAAI,IAAI;IACR;;OAEG;IACH,MAAM,IAAI;IACV;;OAEG;IACH,GAAG,IAAI;IACP;;OAEG;IACH,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C;IACtC;;;;OAIG;IACH,YAAY,CAAC,EAAE,kCAAkC,CAAC;IAClD;;;;;;;;;;OAUG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAGF,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,UAAU,EAAE,gBAAgB,CAAC;IAE7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,uBAAuB,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,kBAAkB,GAAG,sBAAsB,IACvF,CAAC,SAAS;IACR,uBAAuB,EAAE,IAAI,CAAC;CAC/B,GACG,iBAAiB,GACjB,iBAAiB,CAAC"}
@@ -155,4 +155,15 @@ export var UIImagePickerPresentationStyle;
155
155
  */
156
156
  UIImagePickerPresentationStyle["AUTOMATIC"] = "automatic";
157
157
  })(UIImagePickerPresentationStyle || (UIImagePickerPresentationStyle = {}));
158
+ export var CameraType;
159
+ (function (CameraType) {
160
+ /**
161
+ * Back/rear camera.
162
+ */
163
+ CameraType["back"] = "back";
164
+ /**
165
+ * Front camera
166
+ */
167
+ CameraType["front"] = "front";
168
+ })(CameraType || (CameraType = {}));
158
169
  //# sourceMappingURL=ImagePicker.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImagePicker.types.js","sourceRoot":"","sources":["../src/ImagePicker.types.ts"],"names":[],"mappings":"AAmBA,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nC;;OAEG;IACH,6EAA2C,CAAA;IAC3C;;OAEG;IACH,qDAAmB,CAAA;IACnB;;;;;OAKG;IACH,yDAAuB,CAAA;AACzB,CAAC,EApCW,8BAA8B,KAA9B,8BAA8B,QAoCzC","sourcesContent":["import { PermissionResponse } from 'expo-modules-core';\n\n// @needsAudit\n/**\n * Alias for `PermissionResponse` type exported by `expo-modules-core`.\n */\nexport type CameraPermissionResponse = PermissionResponse;\n\n// @needsAudit\n/**\n * Extends `PermissionResponse` type exported by `expo-modules-core`, containing additional iOS-specific field.\n */\nexport type MediaLibraryPermissionResponse = PermissionResponse & {\n /**\n * @platform ios\n */\n accessPrivileges?: 'all' | 'limited' | 'none';\n};\n\n// @needsAudit\nexport enum MediaTypeOptions {\n /**\n * Images and videos.\n */\n All = 'All',\n /**\n * Only videos.\n */\n Videos = 'Videos',\n /**\n * Only images.\n */\n Images = 'Images',\n}\n\n// @needsAudit\nexport enum VideoExportPreset {\n /**\n * Resolution: __Unchanged__ •\n * Video compression: __None__ •\n * Audio compression: __None__\n */\n Passthrough = 0,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n LowQuality = 1,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n MediumQuality = 2,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n HighestQuality = 3,\n /**\n * Resolution: __640 × 480__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_640x480 = 4,\n /**\n * Resolution: __960 × 540__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_960x540 = 5,\n /**\n * Resolution: __1280 × 720__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_1280x720 = 6,\n /**\n * Resolution: __1920 × 1080__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_1920x1080 = 7,\n /**\n * Resolution: __3840 × 2160__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_3840x2160 = 8,\n /**\n * Resolution: __1920 × 1080__ •\n * Video compression: __HEVC__ •\n * Audio compression: __AAC__\n */\n HEVC_1920x1080 = 9,\n /**\n * Resolution: __3840 × 2160__ •\n * Video compression: __HEVC__ •\n * Audio compression: __AAC__\n */\n HEVC_3840x2160 = 10,\n}\n\n// @needsAudit\nexport enum UIImagePickerControllerQualityType {\n /**\n * Highest available resolution.\n */\n High = 0,\n /**\n * Depends on the device.\n */\n Medium = 1,\n /**\n * Depends on the device.\n */\n Low = 2,\n /**\n * 640 × 480\n */\n VGA640x480 = 3,\n /**\n * 1280 × 720\n */\n IFrame1280x720 = 4,\n /**\n * 960 × 540\n */\n IFrame960x540 = 5,\n}\n\n/**\n * Picker presentation style. Its values are directly mapped to the [`UIModalPresentationStyle`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle).\n *\n * @platform ios\n */\nexport enum UIImagePickerPresentationStyle {\n /**\n * A presentation style in which the presented picker covers the screen.\n */\n FULL_SCREEN = 'fullScreen',\n /**\n * A presentation style that partially covers the underlying content.\n */\n PAGE_SHEET = 'pageSheet',\n /**\n * A presentation style that displays the picker centered in the screen.\n */\n FORM_SHEET = 'formSheet',\n /**\n * A presentation style where the picker is displayed over the app's content.\n */\n CURRENT_CONTEXT = 'currentContext',\n /**\n * A presentation style in which the picker view covers the screen.\n */\n OVER_FULL_SCREEN = 'overFullScreen',\n /**\n * A presentation style where the picker is displayed over the app's content.\n */\n OVER_CURRENT_CONTEXT = 'overCurrentContext',\n /**\n * A presentation style where the picker is displayed in a popover view.\n */\n POPOVER = 'popover',\n /**\n * The default presentation style chosen by the system.\n * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.\n *\n * @platform ios 13+\n */\n AUTOMATIC = 'automatic',\n}\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerAsset` instead\n */\nexport type ImageInfo = ImagePickerAsset;\n\n/**\n * Represents an asset (image or video) returned by the image picker or camera.\n */\nexport type ImagePickerAsset = {\n /**\n * URI to the local image or video file (usable as the source of an `Image` element, in the case of\n * an image) and `width` and `height` specify the dimensions of the media.\n */\n uri: string;\n /**\n * The unique ID that represents the picked image or video, if picked from the library. It can be used\n * by [expo-media-library](./media-library) to manage the picked asset.\n *\n * > This might be `null` when the ID is unavailable or the user gave limited permission to access the media library.\n * > On Android, the ID is unavailable when the user selects a photo by directly browsing file system.\n *\n * @platform ios\n * @platform android\n */\n assetId?: string | null;\n /**\n * Width of the image or video.\n */\n width: number;\n /**\n * Height of the image or video.\n */\n height: number;\n /**\n * The type of the asset.\n */\n type?: 'image' | 'video';\n /**\n * Preferred filename to use when saving this item. This might be `null` when the name is unavailable\n * or user gave limited permission to access the media library.\n *\n * @platform ios\n */\n fileName?: string | null;\n /**\n * File size of the picked image or video, in bytes.\n *\n * @platform ios\n */\n fileSize?: number;\n /**\n * The `exif` field is included if the `exif` option is truthy, and is an object containing the\n * image's EXIF data. The names of this object's properties are EXIF tags and the values are the\n * respective EXIF values for those tags.\n */\n exif?: Record<string, any> | null;\n /**\n * When the `base64` option is truthy, it is a Base64-encoded string of the selected image's JPEG data, otherwise `null`.\n * If you prepend this with `'data:image/jpeg;base64,'` to create a data URI,\n * you can use it as the source of an `Image` element; for example:\n * ```ts\n * <Image\n * source={{ uri: 'data:image/jpeg;base64,' + asset.base64 }}\n * style={{ width: 200, height: 200 }}\n * />\n * ```\n */\n base64?: string | null;\n /**\n * Length of the video in milliseconds or `null` if the asset is not a video.\n */\n duration?: number | null;\n};\n\n// @needsAudit\nexport type ImagePickerErrorResult = {\n /**\n * The error code.\n */\n code: string;\n /**\n * The error message.\n */\n message: string;\n /**\n * The exception which caused the error.\n */\n exception?: string;\n};\n\n// @needsAudit\n/**\n * Type representing successful and canceled pick result.\n */\nexport type ImagePickerResult = ImagePickerSuccessResult | ImagePickerCanceledResult;\n\n/**\n * Type representing successful pick result.\n */\nexport type ImagePickerSuccessResult = {\n /**\n * Boolean flag set to `false` showing that the request was successful.\n */\n canceled: false;\n /**\n * An array of picked assets.\n */\n assets: ImagePickerAsset[];\n};\n\n/**\n * Type representing canceled pick result.\n */\nexport type ImagePickerCanceledResult = {\n /**\n * Boolean flag set to `true` showing that the request was canceled.\n */\n canceled: true;\n /**\n * `null` signifying that the request was canceled.\n */\n assets: null;\n};\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerResult` instead.\n */\nexport type ImagePickerCancelledResult = ImagePickerCanceledResult;\n\n/**\n * @hidden\n * @deprecated `ImagePickerMultipleResult` has been deprecated in favor of `ImagePickerResult`.\n */\nexport type ImagePickerMultipleResult = ImagePickerResult;\n\n// @needsAudit\nexport type ImagePickerOptions = {\n /**\n * Whether to show a UI to edit the image after it is picked. On Android the user can crop and\n * rotate the image and on iOS simply crop it.\n *\n * > Cropping multiple images is not supported - this option is mutually exclusive with `allowsMultipleSelection`.\n * > On iOS, this option is ignored if `allowsMultipleSelection` is enabled.\n *\n * @default false\n * @platform ios\n * @platform android\n */\n allowsEditing?: boolean;\n /**\n * An array with two entries `[x, y]` specifying the aspect ratio to maintain if the user is\n * allowed to edit the image (by passing `allowsEditing: true`). This is only applicable on\n * Android, since on iOS the crop rectangle is always a square.\n */\n aspect?: [number, number];\n /**\n * Specify the quality of compression, from `0` to `1`. `0` means compress for small size,\n * `1` means compress for maximum quality.\n * > Note: If the selected image has been compressed before, the size of the output file may be\n * > bigger than the size of the original image.\n *\n * > Note: On iOS, if a `.bmp` or `.png` image is selected from the library, this option is ignored.\n *\n * @default 0.2\n * @platform ios\n * @platform android\n */\n quality?: number;\n /**\n * Choose what type of media to pick.\n * @default ImagePicker.MediaTypeOptions.Images\n */\n mediaTypes?: MediaTypeOptions;\n /**\n * Whether to also include the EXIF data for the image. On iOS the EXIF data does not include GPS\n * tags in the camera case.\n */\n exif?: boolean;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64?: boolean;\n /**\n * Specify preset which will be used to compress selected video.\n * @default ImagePicker.VideoExportPreset.Passthrough\n * @platform ios 11+\n * @deprecated See [`videoExportPreset`](https://developer.apple.com/documentation/uikit/uiimagepickercontroller/2890964-videoexportpreset?language=objc)\n * in Apple documentation.\n */\n videoExportPreset?: VideoExportPreset;\n /**\n * Specify the quality of recorded videos. Defaults to the highest quality available for the device.\n * @default ImagePicker.UIImagePickerControllerQualityType.High\n * @platform ios\n */\n videoQuality?: UIImagePickerControllerQualityType;\n /**\n * Whether or not to allow selecting multiple media files at once.\n *\n * > Cropping multiple images is not supported - this option is mutually exclusive with `allowsEditing`.\n * > If this option is enabled, then `allowsEditing` is ignored.\n *\n * @default false\n * @platform ios 14+\n * @platform android\n * @platform web\n */\n allowsMultipleSelection?: boolean;\n /**\n * The maximum number of items that user can select. Applicable when `allowsMultipleSelection` is enabled.\n * Setting the value to `0` sets the selection limit to the maximum that the system supports.\n *\n * @platform ios 14+\n * @default 0\n */\n selectionLimit?: number;\n /**\n * Whether to display number badges when assets are selected. The badges are numbered\n * in selection order. Assets are then returned in the exact same order they were selected.\n *\n * > Assets should be returned in the selection order regardless of this option,\n * > but there is no guarantee that it is always true when this option is disabled.\n *\n * @platform ios 15+\n * @default false\n */\n orderedSelection?: boolean;\n /**\n * Maximum duration, in seconds, for video recording. Setting this to `0` disables the limit.\n * Defaults to `0` (no limit).\n * - **On iOS**, when `allowsEditing` is set to `true`, maximum duration is limited to 10 minutes.\n * This limit is applied automatically, if `0` or no value is specified.\n * - **On Android**, effect of this option depends on support of installed camera app.\n * - **On Web** this option has no effect - the limit is browser-dependant.\n */\n videoMaxDuration?: number;\n /**\n * Choose [presentation style](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle?language=objc)\n * to customize view during taking photo/video.\n * @default ImagePicker.UIImagePickerPresentationStyle.Automatic\n * @platform ios\n */\n presentationStyle?: UIImagePickerPresentationStyle;\n};\n\n// @needsAudit\nexport type OpenFileBrowserOptions = {\n /**\n * Choose what type of media to pick.\n * @default ImagePicker.MediaTypeOptions.Images\n */\n mediaTypes: MediaTypeOptions;\n // @docsMissing\n capture?: boolean;\n /**\n * Whether or not to allow selecting multiple media files at once.\n * @platform web\n */\n allowsMultipleSelection: boolean;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64: boolean;\n};\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerResult` or `OpenFileBrowserOptions` instead.\n */\nexport type ExpandImagePickerResult<T extends ImagePickerOptions | OpenFileBrowserOptions> =\n T extends {\n allowsMultipleSelection: true;\n }\n ? ImagePickerResult\n : ImagePickerResult;\n"]}
1
+ {"version":3,"file":"ImagePicker.types.js","sourceRoot":"","sources":["../src/ImagePicker.types.ts"],"names":[],"mappings":"AAmBA,cAAc;AACd,MAAM,CAAN,IAAY,gBAaX;AAbD,WAAY,gBAAgB;IAC1B;;OAEG;IACH,+BAAW,CAAA;IACX;;OAEG;IACH,qCAAiB,CAAA;IACjB;;OAEG;IACH,qCAAiB,CAAA;AACnB,CAAC,EAbW,gBAAgB,KAAhB,gBAAgB,QAa3B;AAED,cAAc;AACd,MAAM,CAAN,IAAY,iBAmEX;AAnED,WAAY,iBAAiB;IAC3B;;;;OAIG;IACH,uEAAe,CAAA;IACf;;;;OAIG;IACH,qEAAc,CAAA;IACd;;;;OAIG;IACH,2EAAiB,CAAA;IACjB;;;;OAIG;IACH,6EAAkB,CAAA;IAClB;;;;OAIG;IACH,yEAAgB,CAAA;IAChB;;;;OAIG;IACH,yEAAgB,CAAA;IAChB;;;;OAIG;IACH,2EAAiB,CAAA;IACjB;;;;OAIG;IACH,6EAAkB,CAAA;IAClB;;;;OAIG;IACH,6EAAkB,CAAA;IAClB;;;;OAIG;IACH,6EAAkB,CAAA;IAClB;;;;OAIG;IACH,8EAAmB,CAAA;AACrB,CAAC,EAnEW,iBAAiB,KAAjB,iBAAiB,QAmE5B;AAED,cAAc;AACd,MAAM,CAAN,IAAY,kCAyBX;AAzBD,WAAY,kCAAkC;IAC5C;;OAEG;IACH,2FAAQ,CAAA;IACR;;OAEG;IACH,+FAAU,CAAA;IACV;;OAEG;IACH,yFAAO,CAAA;IACP;;OAEG;IACH,uGAAc,CAAA;IACd;;OAEG;IACH,+GAAkB,CAAA;IAClB;;OAEG;IACH,6GAAiB,CAAA;AACnB,CAAC,EAzBW,kCAAkC,KAAlC,kCAAkC,QAyB7C;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,8BAoCX;AApCD,WAAY,8BAA8B;IACxC;;OAEG;IACH,4DAA0B,CAAA;IAC1B;;OAEG;IACH,0DAAwB,CAAA;IACxB;;OAEG;IACH,0DAAwB,CAAA;IACxB;;OAEG;IACH,oEAAkC,CAAA;IAClC;;OAEG;IACH,qEAAmC,CAAA;IACnC;;OAEG;IACH,6EAA2C,CAAA;IAC3C;;OAEG;IACH,qDAAmB,CAAA;IACnB;;;;;OAKG;IACH,yDAAuB,CAAA;AACzB,CAAC,EApCW,8BAA8B,KAA9B,8BAA8B,QAoCzC;AAED,MAAM,CAAN,IAAY,UASX;AATD,WAAY,UAAU;IACpB;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,6BAAe,CAAA;AACjB,CAAC,EATW,UAAU,KAAV,UAAU,QASrB","sourcesContent":["import { PermissionResponse } from 'expo-modules-core';\n\n// @needsAudit\n/**\n * Alias for `PermissionResponse` type exported by `expo-modules-core`.\n */\nexport type CameraPermissionResponse = PermissionResponse;\n\n// @needsAudit\n/**\n * Extends `PermissionResponse` type exported by `expo-modules-core`, containing additional iOS-specific field.\n */\nexport type MediaLibraryPermissionResponse = PermissionResponse & {\n /**\n * @platform ios\n */\n accessPrivileges?: 'all' | 'limited' | 'none';\n};\n\n// @needsAudit\nexport enum MediaTypeOptions {\n /**\n * Images and videos.\n */\n All = 'All',\n /**\n * Only videos.\n */\n Videos = 'Videos',\n /**\n * Only images.\n */\n Images = 'Images',\n}\n\n// @needsAudit\nexport enum VideoExportPreset {\n /**\n * Resolution: __Unchanged__ •\n * Video compression: __None__ •\n * Audio compression: __None__\n */\n Passthrough = 0,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n LowQuality = 1,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n MediumQuality = 2,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n HighestQuality = 3,\n /**\n * Resolution: __640 × 480__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_640x480 = 4,\n /**\n * Resolution: __960 × 540__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_960x540 = 5,\n /**\n * Resolution: __1280 × 720__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_1280x720 = 6,\n /**\n * Resolution: __1920 × 1080__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_1920x1080 = 7,\n /**\n * Resolution: __3840 × 2160__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_3840x2160 = 8,\n /**\n * Resolution: __1920 × 1080__ •\n * Video compression: __HEVC__ •\n * Audio compression: __AAC__\n */\n HEVC_1920x1080 = 9,\n /**\n * Resolution: __3840 × 2160__ •\n * Video compression: __HEVC__ •\n * Audio compression: __AAC__\n */\n HEVC_3840x2160 = 10,\n}\n\n// @needsAudit\nexport enum UIImagePickerControllerQualityType {\n /**\n * Highest available resolution.\n */\n High = 0,\n /**\n * Depends on the device.\n */\n Medium = 1,\n /**\n * Depends on the device.\n */\n Low = 2,\n /**\n * 640 × 480\n */\n VGA640x480 = 3,\n /**\n * 1280 × 720\n */\n IFrame1280x720 = 4,\n /**\n * 960 × 540\n */\n IFrame960x540 = 5,\n}\n\n/**\n * Picker presentation style. Its values are directly mapped to the [`UIModalPresentationStyle`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle).\n *\n * @platform ios\n */\nexport enum UIImagePickerPresentationStyle {\n /**\n * A presentation style in which the presented picker covers the screen.\n */\n FULL_SCREEN = 'fullScreen',\n /**\n * A presentation style that partially covers the underlying content.\n */\n PAGE_SHEET = 'pageSheet',\n /**\n * A presentation style that displays the picker centered in the screen.\n */\n FORM_SHEET = 'formSheet',\n /**\n * A presentation style where the picker is displayed over the app's content.\n */\n CURRENT_CONTEXT = 'currentContext',\n /**\n * A presentation style in which the picker view covers the screen.\n */\n OVER_FULL_SCREEN = 'overFullScreen',\n /**\n * A presentation style where the picker is displayed over the app's content.\n */\n OVER_CURRENT_CONTEXT = 'overCurrentContext',\n /**\n * A presentation style where the picker is displayed in a popover view.\n */\n POPOVER = 'popover',\n /**\n * The default presentation style chosen by the system.\n * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.\n *\n * @platform ios 13+\n */\n AUTOMATIC = 'automatic',\n}\n\nexport enum CameraType {\n /**\n * Back/rear camera.\n */\n back = 'back',\n /**\n * Front camera\n */\n front = 'front',\n}\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerAsset` instead\n */\nexport type ImageInfo = ImagePickerAsset;\n\n/**\n * Represents an asset (image or video) returned by the image picker or camera.\n */\nexport type ImagePickerAsset = {\n /**\n * URI to the local image or video file (usable as the source of an `Image` element, in the case of\n * an image) and `width` and `height` specify the dimensions of the media.\n */\n uri: string;\n /**\n * The unique ID that represents the picked image or video, if picked from the library. It can be used\n * by [expo-media-library](./media-library) to manage the picked asset.\n *\n * > This might be `null` when the ID is unavailable or the user gave limited permission to access the media library.\n * > On Android, the ID is unavailable when the user selects a photo by directly browsing file system.\n *\n * @platform ios\n * @platform android\n */\n assetId?: string | null;\n /**\n * Width of the image or video.\n */\n width: number;\n /**\n * Height of the image or video.\n */\n height: number;\n /**\n * The type of the asset.\n */\n type?: 'image' | 'video';\n /**\n * Preferred filename to use when saving this item. This might be `null` when the name is unavailable\n * or user gave limited permission to access the media library.\n *\n * @platform ios\n */\n fileName?: string | null;\n /**\n * File size of the picked image or video, in bytes.\n *\n * @platform ios\n */\n fileSize?: number;\n /**\n * The `exif` field is included if the `exif` option is truthy, and is an object containing the\n * image's EXIF data. The names of this object's properties are EXIF tags and the values are the\n * respective EXIF values for those tags.\n */\n exif?: Record<string, any> | null;\n /**\n * When the `base64` option is truthy, it is a Base64-encoded string of the selected image's JPEG data, otherwise `null`.\n * If you prepend this with `'data:image/jpeg;base64,'` to create a data URI,\n * you can use it as the source of an `Image` element; for example:\n * ```ts\n * <Image\n * source={{ uri: 'data:image/jpeg;base64,' + asset.base64 }}\n * style={{ width: 200, height: 200 }}\n * />\n * ```\n */\n base64?: string | null;\n /**\n * Length of the video in milliseconds or `null` if the asset is not a video.\n */\n duration?: number | null;\n};\n\n// @needsAudit\nexport type ImagePickerErrorResult = {\n /**\n * The error code.\n */\n code: string;\n /**\n * The error message.\n */\n message: string;\n /**\n * The exception which caused the error.\n */\n exception?: string;\n};\n\n// @needsAudit\n/**\n * Type representing successful and canceled pick result.\n */\nexport type ImagePickerResult = ImagePickerSuccessResult | ImagePickerCanceledResult;\n\n/**\n * Type representing successful pick result.\n */\nexport type ImagePickerSuccessResult = {\n /**\n * Boolean flag set to `false` showing that the request was successful.\n */\n canceled: false;\n /**\n * An array of picked assets.\n */\n assets: ImagePickerAsset[];\n};\n\n/**\n * Type representing canceled pick result.\n */\nexport type ImagePickerCanceledResult = {\n /**\n * Boolean flag set to `true` showing that the request was canceled.\n */\n canceled: true;\n /**\n * `null` signifying that the request was canceled.\n */\n assets: null;\n};\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerResult` instead.\n */\nexport type ImagePickerCancelledResult = ImagePickerCanceledResult;\n\n/**\n * @hidden\n * @deprecated `ImagePickerMultipleResult` has been deprecated in favor of `ImagePickerResult`.\n */\nexport type ImagePickerMultipleResult = ImagePickerResult;\n\n// @needsAudit\nexport type ImagePickerOptions = {\n /**\n * Whether to show a UI to edit the image after it is picked. On Android the user can crop and\n * rotate the image and on iOS simply crop it.\n *\n * > - Cropping multiple images is not supported - this option is mutually exclusive with `allowsMultipleSelection`.\n * > - On iOS, this option is ignored if `allowsMultipleSelection` is enabled.\n * > - On iOS cropping a `.bmp` image will convert it to `.png`.\n *\n * @default false\n * @platform ios\n * @platform android\n */\n allowsEditing?: boolean;\n /**\n * An array with two entries `[x, y]` specifying the aspect ratio to maintain if the user is\n * allowed to edit the image (by passing `allowsEditing: true`). This is only applicable on\n * Android, since on iOS the crop rectangle is always a square.\n */\n aspect?: [number, number];\n /**\n * Specify the quality of compression, from `0` to `1`. `0` means compress for small size,\n * `1` means compress for maximum quality.\n * > Note: If the selected image has been compressed before, the size of the output file may be\n * > bigger than the size of the original image.\n *\n * > Note: On iOS, if a `.bmp` or `.png` image is selected from the library, this option is ignored.\n *\n * @default 0.2\n * @platform ios\n * @platform android\n */\n quality?: number;\n /**\n * Choose what type of media to pick.\n * @default ImagePicker.MediaTypeOptions.Images\n */\n mediaTypes?: MediaTypeOptions;\n /**\n * Whether to also include the EXIF data for the image. On iOS the EXIF data does not include GPS\n * tags in the camera case.\n */\n exif?: boolean;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64?: boolean;\n /**\n * Specify preset which will be used to compress selected video.\n * @default ImagePicker.VideoExportPreset.Passthrough\n * @platform ios 11+\n * @deprecated See [`videoExportPreset`](https://developer.apple.com/documentation/uikit/uiimagepickercontroller/2890964-videoexportpreset?language=objc)\n * in Apple documentation.\n */\n videoExportPreset?: VideoExportPreset;\n /**\n * Specify the quality of recorded videos. Defaults to the highest quality available for the device.\n * @default ImagePicker.UIImagePickerControllerQualityType.High\n * @platform ios\n */\n videoQuality?: UIImagePickerControllerQualityType;\n /**\n * Whether or not to allow selecting multiple media files at once.\n *\n * > Cropping multiple images is not supported - this option is mutually exclusive with `allowsEditing`.\n * > If this option is enabled, then `allowsEditing` is ignored.\n *\n * @default false\n * @platform ios 14+\n * @platform android\n * @platform web\n */\n allowsMultipleSelection?: boolean;\n /**\n * The maximum number of items that user can select. Applicable when `allowsMultipleSelection` is enabled.\n * Setting the value to `0` sets the selection limit to the maximum that the system supports.\n *\n * @platform ios 14+\n * @default 0\n */\n selectionLimit?: number;\n /**\n * Whether to display number badges when assets are selected. The badges are numbered\n * in selection order. Assets are then returned in the exact same order they were selected.\n *\n * > Assets should be returned in the selection order regardless of this option,\n * > but there is no guarantee that it is always true when this option is disabled.\n *\n * @platform ios 15+\n * @default false\n */\n orderedSelection?: boolean;\n /**\n * Maximum duration, in seconds, for video recording. Setting this to `0` disables the limit.\n * Defaults to `0` (no limit).\n * - **On iOS**, when `allowsEditing` is set to `true`, maximum duration is limited to 10 minutes.\n * This limit is applied automatically, if `0` or no value is specified.\n * - **On Android**, effect of this option depends on support of installed camera app.\n * - **On Web** this option has no effect - the limit is browser-dependant.\n */\n videoMaxDuration?: number;\n /**\n * Choose [presentation style](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle?language=objc)\n * to customize view during taking photo/video.\n * @default ImagePicker.UIImagePickerPresentationStyle.Automatic\n * @platform ios\n */\n presentationStyle?: UIImagePickerPresentationStyle;\n /**\n * Selects the camera-facing type. The `CameraType` enum provides two options:\n * `front` for the front-facing camera and `back` for the back-facing camera.\n * - **On Android**, the behavior of this option may vary based on the camera app installed on the device.\n * @default CameraType.back\n * @platform ios\n * @platform android\n */\n cameraType?: CameraType;\n};\n\n// @needsAudit\nexport type OpenFileBrowserOptions = {\n /**\n * Choose what type of media to pick.\n * @default ImagePicker.MediaTypeOptions.Images\n */\n mediaTypes: MediaTypeOptions;\n // @docsMissing\n capture?: boolean;\n /**\n * Whether or not to allow selecting multiple media files at once.\n * @platform web\n */\n allowsMultipleSelection: boolean;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64: boolean;\n};\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerResult` or `OpenFileBrowserOptions` instead.\n */\nexport type ExpandImagePickerResult<T extends ImagePickerOptions | OpenFileBrowserOptions> =\n T extends {\n allowsMultipleSelection: true;\n }\n ? ImagePickerResult\n : ImagePickerResult;\n"]}
@@ -41,7 +41,6 @@ internal struct ImagePickerOptions: Record {
41
41
  @Field
42
42
  var presentationStyle: PresentationStyle = .automatic
43
43
 
44
- // TODO: (bbarthec): undocumented
45
44
  @Field
46
45
  var cameraType: CameraType = .back
47
46
 
@@ -85,7 +85,11 @@ internal struct MediaHandler {
85
85
  // as calling this already requires media library permission, we can access it here
86
86
  // if user gave limited permissions, in the worst case this will be null
87
87
  let asset = mediaInfo[.phAsset] as? PHAsset
88
- let fileName = asset?.value(forKey: "filename") as? String
88
+ var fileName = asset?.value(forKey: "filename") as? String
89
+ // Extension will change to png when editing BMP files, reflect that change in fileName
90
+ if let unwrappedName = fileName {
91
+ fileName = replaceFileExtension(fileName: unwrappedName, targetExtension: fileExtension.lowercased())
92
+ }
89
93
  let fileSize = getFileSize(from: targetUrl)
90
94
 
91
95
  let base64 = try ImageUtils.optionallyReadBase64From(imageData: imageData,
@@ -251,6 +255,22 @@ internal struct MediaHandler {
251
255
 
252
256
  // MARK: - utils
253
257
 
258
+ private func replaceFileExtension(fileName: String, targetExtension: String) -> String {
259
+ if !fileName.lowercased().hasSuffix(targetExtension.lowercased()) {
260
+ return deleteFileExtension(fileName: fileName) + targetExtension
261
+ }
262
+ return fileName
263
+ }
264
+
265
+ private func deleteFileExtension(fileName: String) -> String {
266
+ var components = fileName.components(separatedBy: ".")
267
+ guard components.count > 1 else {
268
+ return fileName
269
+ }
270
+ components.removeLast()
271
+ return components.joined(separator: ".")
272
+ }
273
+
254
274
  private func generateUrl(withFileExtension: String) throws -> URL {
255
275
  guard let fileSystem = self.fileSystem else {
256
276
  throw FileSystemModuleNotFoundException()
@@ -338,7 +358,7 @@ private struct ImageUtils {
338
358
  return (data, ".png")
339
359
 
340
360
  case .some(let s) where s.contains("ext=BMP"):
341
- if options.allowsEditing || options.quality != nil {
361
+ if options.allowsEditing {
342
362
  // switch to png if editing
343
363
  let data = image.pngData()
344
364
  return (data, ".png")
@@ -375,6 +395,13 @@ private struct ImageUtils {
375
395
  let preferredFormat = itemProvider.registeredTypeIdentifiers.first
376
396
 
377
397
  switch preferredFormat {
398
+ case UTType.bmp.identifier:
399
+ if options.allowsEditing {
400
+ // switch to png if editing
401
+ let data = image.pngData()
402
+ return (data, ".png")
403
+ }
404
+ return (rawData, ".bmp")
378
405
  case UTType.png.identifier:
379
406
  let data = image.pngData()
380
407
  return (data, ".png")
@@ -589,8 +616,12 @@ private struct VideoUtils {
589
616
 
590
617
  static func readSizeFrom(url: URL) -> CGSize? {
591
618
  let asset = AVURLAsset(url: url)
592
- let size: CGSize? = asset.tracks(withMediaType: .video).first?.naturalSize
593
- return size
619
+ guard let assetTrack = asset.tracks(withMediaType: .video).first else {
620
+ return nil
621
+ }
622
+ // The video could be rotated and the resulting transform can result in a negative width/height.
623
+ let size = assetTrack.naturalSize.applying(assetTrack.preferredTransform)
624
+ return CGSize(width: abs(size.width), height: abs(size.height))
594
625
  }
595
626
 
596
627
  static func readVideoUrlFrom(mediaInfo: MediaInfo) -> URL? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-image-picker",
3
- "version": "14.1.1",
3
+ "version": "14.2.0",
4
4
  "description": "Provides access to the system's UI for selecting images and videos from the phone's library or taking a photo with the camera.",
5
5
  "main": "build/ImagePicker.js",
6
6
  "types": "build/ImagePicker.d.ts",
@@ -36,7 +36,7 @@
36
36
  "preset": "expo-module-scripts"
37
37
  },
38
38
  "dependencies": {
39
- "expo-image-loader": "~4.1.0"
39
+ "expo-image-loader": "~4.2.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "expo-module-scripts": "^3.0.0"
@@ -44,5 +44,5 @@
44
44
  "peerDependencies": {
45
45
  "expo": "*"
46
46
  },
47
- "gitHead": "1f8a6a09570fd451378565ca34933018ce48454e"
47
+ "gitHead": "4ba50c428c8369bb6b3a51a860d4898ad4ccbe78"
48
48
  }
@@ -174,6 +174,17 @@ export enum UIImagePickerPresentationStyle {
174
174
  AUTOMATIC = 'automatic',
175
175
  }
176
176
 
177
+ export enum CameraType {
178
+ /**
179
+ * Back/rear camera.
180
+ */
181
+ back = 'back',
182
+ /**
183
+ * Front camera
184
+ */
185
+ front = 'front',
186
+ }
187
+
177
188
  /**
178
189
  * @hidden
179
190
  * @deprecated Use `ImagePickerAsset` instead
@@ -317,8 +328,9 @@ export type ImagePickerOptions = {
317
328
  * Whether to show a UI to edit the image after it is picked. On Android the user can crop and
318
329
  * rotate the image and on iOS simply crop it.
319
330
  *
320
- * > Cropping multiple images is not supported - this option is mutually exclusive with `allowsMultipleSelection`.
321
- * > On iOS, this option is ignored if `allowsMultipleSelection` is enabled.
331
+ * > - Cropping multiple images is not supported - this option is mutually exclusive with `allowsMultipleSelection`.
332
+ * > - On iOS, this option is ignored if `allowsMultipleSelection` is enabled.
333
+ * > - On iOS cropping a `.bmp` image will convert it to `.png`.
322
334
  *
323
335
  * @default false
324
336
  * @platform ios
@@ -419,6 +431,15 @@ export type ImagePickerOptions = {
419
431
  * @platform ios
420
432
  */
421
433
  presentationStyle?: UIImagePickerPresentationStyle;
434
+ /**
435
+ * Selects the camera-facing type. The `CameraType` enum provides two options:
436
+ * `front` for the front-facing camera and `back` for the back-facing camera.
437
+ * - **On Android**, the behavior of this option may vary based on the camera app installed on the device.
438
+ * @default CameraType.back
439
+ * @platform ios
440
+ * @platform android
441
+ */
442
+ cameraType?: CameraType;
422
443
  };
423
444
 
424
445
  // @needsAudit