Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(camera): add option to exclude Exif data on iOS #1328

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions camera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,15 @@ Request camera and photo album permissions

#### GalleryImageOptions

| Prop | Type | Description | Default | Since |
| ------------------------ | -------------------------------------- | ------------------------------------------------------------------------------------------ | --------------------------- | ----- |
| **`quality`** | <code>number</code> | The quality of image to return as JPEG, from 0-100 | | 1.2.0 |
| **`width`** | <code>number</code> | The desired maximum width of the saved image. The aspect ratio is respected. | | 1.2.0 |
| **`height`** | <code>number</code> | The desired maximum height of the saved image. The aspect ratio is respected. | | 1.2.0 |
| **`correctOrientation`** | <code>boolean</code> | Whether to automatically rotate the image "up" to correct for orientation in portrait mode | <code>: true</code> | 1.2.0 |
| **`presentationStyle`** | <code>'fullscreen' \| 'popover'</code> | iOS only: The presentation style of the Camera. | <code>: 'fullscreen'</code> | 1.2.0 |
| **`limit`** | <code>number</code> | iOS only: Maximum number of pictures the user will be able to choose. | <code>0 (unlimited)</code> | 1.2.0 |
| Prop | Type | Description | Default | Since |
| ------------------------ | -------------------------------------- | -------------------------------------------------------------------------------------------------------- | --------------------------- | ----- |
| **`exif`** | <code>boolean</code> | Whether to include the exif data in the response. If set to `true`, the `photos` permission is required. | <code>: true</code> | 4.2.0 |
| **`quality`** | <code>number</code> | The quality of image to return as JPEG, from 0-100 | | 1.2.0 |
| **`width`** | <code>number</code> | The desired maximum width of the saved image. The aspect ratio is respected. | | 1.2.0 |
| **`height`** | <code>number</code> | The desired maximum height of the saved image. The aspect ratio is respected. | | 1.2.0 |
| **`correctOrientation`** | <code>boolean</code> | Whether to automatically rotate the image "up" to correct for orientation in portrait mode | <code>: true</code> | 1.2.0 |
| **`presentationStyle`** | <code>'fullscreen' \| 'popover'</code> | iOS only: The presentation style of the Camera. | <code>: 'fullscreen'</code> | 1.2.0 |
| **`limit`** | <code>number</code> | iOS only: Maximum number of pictures the user will be able to choose. | <code>0 (unlimited)</code> | 1.2.0 |


#### PermissionStatus
Expand Down
5 changes: 3 additions & 2 deletions camera/ios/Plugin/CameraPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -434,14 +434,15 @@ private extension CameraPlugin {
}

func showPhotos() {
let exif = self.call?.getBool("exif") ?? true
// check for permission
let authStatus = PHPhotoLibrary.authorizationStatus()
if authStatus == .restricted || authStatus == .denied {
if exif && (authStatus == .restricted || authStatus == .denied) {
call?.reject("User denied access to photos")
return
}
// we either already have permission or can prompt
if authStatus == .authorized {
if !exif || authStatus == .authorized {
presentSystemAppropriateImagePicker()
} else {
PHPhotoLibrary.requestAuthorization({ [weak self] (status) in
Expand Down
2 changes: 1 addition & 1 deletion camera/ios/Plugin/ImageSaver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ImageSaver: NSObject {

var onResult: ((Error?) -> Void) = {_ in }

init(image: UIImage, onResult:@escaping ((Error?) -> Void)) {
init(image: UIImage, onResult: @escaping ((Error?) -> Void)) {
self.onResult = onResult
super.init()
UIImageWriteToSavedPhotosAlbum(image, self, #selector(saveResult), nil)
Expand Down
11 changes: 11 additions & 0 deletions camera/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,17 @@ export interface GalleryPhoto {
format: string;
}
export interface GalleryImageOptions {
/**
* Whether to include the exif data in the response.
*
* If set to `true`, the `photos` permission is required.
*
* Only available on iOS.
*
* @default true
* @since 4.2.0
*/
exif?: boolean;
/**
* The quality of image to return as JPEG, from 0-100
*
Expand Down