I am working with an APIs which is throwing error when image is greater than 5MB. Now I want to compress the size of image if image size is greater than 5MB then it should compress that to 5MB. Is there any way to do that other than mentioned method
ImagePicker.pickImage(source: picker.ImageSource.gallery,imageQuality: 50)
or how exactly imageQuality
works If you know the exact behavior then please mention that also.
Thanks!
CodePudding user response:
You can use the flutter_image_compress dependency.
Look this example: https://pub.dev/packages/flutter_image_compress
CodePudding user response:
As of my solution try to use SVG image instead of jpg or png it may help you to reduce size. If You don't find solution then ping me we will try to solve the issue. SVG is highest quality images because it draw by pixels to pixels.
CodePudding user response:
You can try this [click here].
CodePudding user response:
How exactly imageQuality works If you know the exact behavior then please mention that also.
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 supported for certain image types such as JPEG and on Android PNG and WebP, too. If compression is not supported for the image that is picked, a warning message will be logged.
https://pub.dev/documentation/image_picker/latest/image_picker/ImagePicker/pickImage.html