image_picker : compressing is not supported for type (null). 返回原始质量的图像

标签 image flutter dart picker

我想更改所选图像的图像质量,但出现此错误。有谁知道如何解决这一问题? (我从 iOS 设备上得到了一张图片。)

image_picker:类型(空)不支持压缩。返回原始质量的图像

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.

关于image_picker : compressing is not supported for type (null). 返回原始质量的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57472183/

相关文章:

css - 我正在创建一个增量游戏,我正在努力让两个图像相互关联

javascript - 动态调整图像映射和图像的大小

ios - 能否在 detailTextLabel 单元格中显示小图像?

css - Webpack 配置仅用于 css 和图像

flutter - 如何从 Flutter 中的 AlertDialog 中删除对称边距?

flutter - 如何解决抖动错误(操作系统错误 : Access Denied, errno = 5 )?

android - 如何从 Flutter App 连接 Ms SQL?

listbox - 需要访问多个(可能)所选选项

flutter - 从父访问状态 - flutter

datetime - Flutter DateTime,打开关闭如果