mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-31 12:42:50 +08:00
[CB-3453] Save original picture to photo library
- saves original picture when the following camera options are set for no edits (i.e. allowEdit is false, correctOrientation is false, targetWidth/targetHeight are not specified) - this mirrors cordova-android behavior - testing done with mobile-spec auto and manual tests
This commit is contained in:
parent
c1935df8df
commit
767e064c01
@ -303,11 +303,16 @@ static NSSet* org_apache_cordova_validArrowDirections;
|
||||
}
|
||||
|
||||
NSData* data = nil;
|
||||
// returnedImage is the image that is returned to caller and (optionally) saved to photo album
|
||||
UIImage* returnedImage = (scaledImage == nil ? image : scaledImage);
|
||||
|
||||
if (cameraPicker.encodingType == EncodingTypePNG) {
|
||||
data = UIImagePNGRepresentation(scaledImage == nil ? image : scaledImage);
|
||||
data = UIImagePNGRepresentation(returnedImage);
|
||||
} else if ((cameraPicker.allowsEditing==false) && (cameraPicker.targetSize.width <= 0) && (cameraPicker.targetSize.height <= 0) && (cameraPicker.correctOrientation==false)){
|
||||
// use image unedited as requested , don't resize
|
||||
data = UIImageJPEGRepresentation(returnedImage, 1.0);
|
||||
} else {
|
||||
data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage, cameraPicker.quality / 100.0f);
|
||||
data = UIImageJPEGRepresentation(returnedImage, cameraPicker.quality / 100.0f);
|
||||
|
||||
NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
|
||||
if (controllerMetadata) {
|
||||
@ -323,7 +328,8 @@ static NSSet* org_apache_cordova_validArrowDirections;
|
||||
}
|
||||
|
||||
if (cameraPicker.saveToPhotoAlbum) {
|
||||
UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil);
|
||||
ALAssetsLibrary *library = [ALAssetsLibrary new];
|
||||
[library writeImageToSavedPhotosAlbum:returnedImage.CGImage orientation:(ALAssetOrientation)(returnedImage.imageOrientation) completionBlock:nil];
|
||||
}
|
||||
|
||||
if (cameraPicker.returnType == DestinationTypeFileUri) {
|
||||
|
Loading…
Reference in New Issue
Block a user