Image size taken from Flutter Image_Picker plugin is way too big

前端 未结 2 847
醉酒成梦
醉酒成梦 2020-12-17 15:46

I want to use auto-focus on the camera, which is available on the image_picker plugin. However, when I call:

var bytes = new File(imagePath);
var enc = await         


        
相关标签:
2条回答
  • 2020-12-17 16:01

    The camera plugin has 3 default resolutions, and you are probably selecting or defaulting to a lower resolution (than the hardware's full resolution).

    The image_picker plugin doesn't have these presets, but does have some optional arguments on the pickImage method (maxWidth and maxHeight). Experiment setting one or both of these to VGA type resolutions (640, 480, even 800, 600) to see if this reduces the size of the captured image.

    There's also a package called image which would allow you to post-process the image. The sample on the main page does a resize, maintaining aspect ratio.

    0 讨论(0)
  • 2020-12-17 16:15

    Adding small values for the maxHeight and maxWidth parameter in the ImagePicker plugin compresses the size. Here is an example:

    var fileFromCamera = await ImagePicker.pickImage(source: ImageSource.camera, maxHeight: 480, maxWidth: 640);
    
    
    0 讨论(0)
提交回复
热议问题