flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.64k stars 27.35k forks source link

image_picker plugin should allow generation of thumbnail images #26191

Open jonahwilliams opened 5 years ago

jonahwilliams commented 5 years ago

Since the image_picker returns the full resolution images and flutter doesn't automagicly shrink images based on the rendered size, it is easy to trigger OOM/memory pressure when using the returned images. (See https://github.com/flutter/flutter/issues/21571). Regardless of the decisions we make regarding OOM handling for images, it would be nice if the image_picker could also generate much smaller thumbnails to make it easy to avoid loading the full size images.

Example:


ImageWithThumbnail imageWithThumbnail = await ImagePicker.pickImageWithThumbnail(source: ImageSource.camera, thumbnailSize: Size(100, 100));

class ImageWithThumbnail {
  File get image
  File get thumbnail
}
zoechi commented 5 years ago

Seems to depend on #26194

cyanglaz commented 5 years ago

@jonahwilliams We recently introduced a quality parameter to ask image picker to return a lower quality image. With the combination of quality and width and height, one can avoid OOM when using image_picker. Do you think we can close this issue? The PR: https://github.com/flutter/plugins/pull/1896

AndryHTC commented 5 years ago

@cyanglaz I don't think so... The most want to save a full quality image, and managing it, but showing a preview that is not 10+MB... In any way, I've tried a lot this new feature but I cannot get it working. In my case work only the maxHeight and maxSize. Taking the same foto with the Quality parameter set to 1 and to 100, both in gallery or camera, I get the same size of photo with a difference of +-5kb.

cyanglaz commented 4 years ago

Un-assign myself from this issue as I don't have cycle to actively working on it.

mellowcello77 commented 4 years ago

I still think the original request is a good request. I now have to generate thumbnails somewhere else instead of the package that could have done it. Cool package still.

louisdeveseleer commented 2 years ago

I think that would be an awesome feature to add, especially for videos.

adminant commented 1 year ago

Need this feature very much to get rid of extra step compressing image