image_picker:类型 (null) 不支持压缩.以原始质量返回图像



我想更改所选图像的图像质量,但是我收到此错误。有谁知道如何解决这个问题? (我从iOS设备获得了图像。

image_picker: compressing is not supported for type (null). Returning the image with original quality

Future getImageFromCam() async {
File image;
try {
image = await ImagePicker.pickImage(
source: ImageSource.camera, imageQuality: 90);
} on Exception {
_showDialog(context);
}
}

根据源代码,压缩图像仅支持 JPEG
,根据此讨论 https://discussions.apple.com/thread/8319465

All photos taken with the camera will be JPG, unless you go to Settings/Camera - Formats and choose High Efficiency. But High Efficiency will make the photos HEIF,

因此,您可以使用此参考检查相机设置 https://www.mactrast.com/2017/10/set-iphones-camera-back-saving-photos-jpeg-ios-11/

IOS 部分


https://github.com/flutter/plugins/blob/master/packages/image_picker/ios/Classes/FLTImagePickerMetaDataUtil.m

(NSData *)convertImage:(UIImage *)image
usingType:(FLTImagePickerMIMEType)type
quality:(nullable NSNumber *)quality {
if (quality && type != FLTImagePickerMIMETypeJPEG) {
NSLog(@"image_picker: compressing is not supported for type %@. Returning the image with "
@"original quality",
[FLTImagePickerMetaDataUtil imageTypeSuffixFromType:type]);
}

飞镖部分 https://github.com/flutter/plugins/blob/master/packages/image_picker/lib/image_picker.dart

/// The `imageQuality` argument modifies the quality of the image, ranging from 0-100
/// where 100 is the original/max quality. If `imageQuality` is null, the image with
/// the original quality will be returned. Compression is only supportted for certain
/// image types such as JPEG. If compression is not supported for the image that is picked,
/// an warning message will be logged.

最新更新