图片选择器:不支持对空类型进行压缩。将以原始质量返回图片。

3
我想要改变所选图片的质量,但是出现了这个错误。请问有人知道如何解决吗? (图片来自iOS设备。) image_picker: 压缩不支持类型(null)。返回原始质量的图片
Future getImageFromCam() async {
    File image;
    try {
      image = await ImagePicker.pickImage(
          source: ImageSource.camera, imageQuality: 90);
    } on Exception {
      _showDialog(context);
    }
  }
1个回答

0
根据源代码,压缩图像仅支持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]);
  }

Dart部分 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.

谢谢您的回答!我已经弄清楚了! - Ryosuke Yokota
1
你能否详细解释一下你是如何修复这个错误的? - Chirag Bhansali

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接