Filip
Filip

Reputation: 2411

How to scale down image when it's too big?

I'd like to reduce the size of the photo when it exceeds e.g. 250kb, and keep the proportions. How to do this? Something like, I take a photo (5 MB) and I want to change size to 250kb before uploading on server. How to do it?

This is how I take camera picture.

  File imageFile;
    imageFile = await ImagePicker.pickImage(source: ImageSource.camera);

Upvotes: 1

Views: 100

Answers (1)

griffins
griffins

Reputation: 8246

image picker has a property imageQuality. assert(imageQuality == null || (imageQuality >= 0 && imageQuality <= 100));

to set the quality/reduce size in % use

await ImagePicker.pickImage(
        source: ImageSource.camera, imageQuality: 50);

Upvotes: 1

Related Questions