Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions packages/image_picker/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.4+4

* Support adding WebP for iOS
Comment thread
TrGiLong marked this conversation as resolved.
Outdated

## 0.8.4+3

* Suppress a unchecked cast build warning.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,51 +82,61 @@ - (void)start {
}
if (@available(iOS 14, *)) {
[self setExecuting:YES];
[self.result.itemProvider
loadObjectOfClass:[UIImage class]
completionHandler:^(__kindof id<NSItemProviderReading> _Nullable image,
NSError *_Nullable error) {
if ([image isKindOfClass:[UIImage class]]) {
__block UIImage *localImage = image;
PHAsset *originalAsset =
[FLTImagePickerPhotoAssetUtil getAssetFromPHPickerResult:self.result];

if (self.maxWidth != (id)[NSNull null] || self.maxHeight != (id)[NSNull null]) {
localImage = [FLTImagePickerImageUtil scaledImage:localImage
maxWidth:self.maxWidth
maxHeight:self.maxHeight
isMetadataAvailable:originalAsset != nil];
}
__block NSString *savedPath;
if (!originalAsset) {
// Image picked without an original asset (e.g. User pick image without permission)
savedPath =
[FLTImagePickerPhotoAssetUtil saveImageWithPickerInfo:nil
image:localImage
imageQuality:self.desiredImageQuality];
[self completeOperationWithPath:savedPath];
} else {
[[PHImageManager defaultManager]
requestImageDataForAsset:originalAsset
options:nil
resultHandler:^(
NSData *_Nullable imageData, NSString *_Nullable dataUTI,
UIImageOrientation orientation, NSDictionary *_Nullable info) {
// maxWidth and maxHeight are used only for GIF images.
savedPath = [FLTImagePickerPhotoAssetUtil
saveImageWithOriginalImageData:imageData
image:localImage
maxWidth:self.maxWidth
maxHeight:self.maxHeight
imageQuality:self.desiredImageQuality];
[self completeOperationWithPath:savedPath];
}];
}
}
NSString *webpIdentifier = @"org.webmproject.webp";
Comment thread
TrGiLong marked this conversation as resolved.
Outdated
if ([self.result.itemProvider hasItemConformingToTypeIdentifier:webpIdentifier]) {
[self.result.itemProvider loadDataRepresentationForTypeIdentifier:webpIdentifier completionHandler:^(NSData * _Nullable data, NSError * _Nullable error) {
__block UIImage *image = [[UIImage alloc] initWithData:data];
Comment thread
TrGiLong marked this conversation as resolved.
Outdated
[self processImage:image];
}];
return;
}

[self.result.itemProvider loadObjectOfClass:[UIImage class] completionHandler:^(__kindof id<NSItemProviderReading> _Nullable image, NSError *_Nullable error) {
if ([image isKindOfClass:[UIImage class]]) {
[self processImage:image];
}
}];
} else {
[self setFinished:YES];
Comment thread
stuartmorgan-g marked this conversation as resolved.
}
}

- (void)processImage:(UIImage *)image API_AVAILABLE(ios(14)); {
Comment thread
TrGiLong marked this conversation as resolved.
Outdated
__block UIImage *localImage = image;
Comment thread
TrGiLong marked this conversation as resolved.
Outdated
PHAsset *originalAsset =
[FLTImagePickerPhotoAssetUtil getAssetFromPHPickerResult:self.result];

if (self.maxWidth != (id)[NSNull null] || self.maxHeight != (id)[NSNull null]) {
localImage = [FLTImagePickerImageUtil scaledImage:localImage
maxWidth:self.maxWidth
maxHeight:self.maxHeight
isMetadataAvailable:originalAsset != nil];
}
__block NSString *savedPath;
Comment thread
TrGiLong marked this conversation as resolved.
Outdated
if (!originalAsset) {
// Image picked without an original asset (e.g. User pick image without permission)
savedPath =
[FLTImagePickerPhotoAssetUtil saveImageWithPickerInfo:nil
image:localImage
imageQuality:self.desiredImageQuality];
[self completeOperationWithPath:savedPath];
} else {
[[PHImageManager defaultManager]
requestImageDataForAsset:originalAsset
options:nil
resultHandler:^(
NSData *_Nullable imageData, NSString *_Nullable dataUTI,
UIImageOrientation orientation, NSDictionary *_Nullable info) {
// maxWidth and maxHeight are used only for GIF images.
savedPath = [FLTImagePickerPhotoAssetUtil
saveImageWithOriginalImageData:imageData
image:localImage
maxWidth:self.maxWidth
maxHeight:self.maxHeight
imageQuality:self.desiredImageQuality];
[self completeOperationWithPath:savedPath];
}];
}
}

@end
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for selecting images from the Android and iOS image
library, and taking new pictures with the camera.
repository: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
version: 0.8.4+3
version: 0.8.4+4

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down