2

I am facing an issue where the size of the picked image in the app is significantly smaller than the original image in the phone's gallery.


Original image 14.5 MB but after picking it, its 324 KB without any quality setting.


In Document enter image description here

in my flutter app enter image description here

Here are the relevant code snippets:

    // image_picker: ^0.8.7+1 
    // https://pub.dev/packages/image_picker

    final imagePicker = ImagePicker();
    final pickedImage = await imagePicker.pickImage(source: ImageSource.gallery);

    if (pickedImage != null) {
      final originalImage = File(pickedImage.path);
      final imageSize = originalImage.lengthSync();
      
      setState(() {
        _image = originalImage;
        _imageSize = imageSize;
        _imageWidth = image.width;
        _imageHeight = image.height;
      });
    }

Could anyone please help me understand why and how its happening and how to pick images with original size?

1 Answers1

0

specify the imageQuality parameter when picking the image.

final pickedImage = await imagePicker.pickImage(source: 
ImageSource.gallery, imageQuality: 100,); 
  • When picking an image from the gallery in Flutter, the size of the image might be reduced by default to optimize memory usage and performance. To maintain the original size of the image, you can use the image_picker package and specify the imageQuality parameter when picking the image. – Sachin Patil Aug 03 '23 at 07:52
  • Garbage answer, please provide reasonable source and response. The default image quality is already 100 – actuallynoneed Aug 03 '23 at 14:46
  • From documentation : 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. – actuallynoneed Aug 03 '23 at 14:46
  • Please provide the complete code for this page – Sachin Patil Aug 11 '23 at 11:12