flutter_image_compress icon indicating copy to clipboard operation
flutter_image_compress copied to clipboard

[Feature request] Return XFile or Path instead of Uint8List for compressions

Open ynnob opened this issue 1 year ago • 0 comments

Platforms

dart, Android, iOS, macOS, Web, Windows, Linux

Description

Return the path to the compressed cache file instead of the Uint8List. At the moment, the compression creates a File in the cache directory and only returns the bytes. There is no way to use the file that has been created in the cache directory by the compression method.

Why

Returning only the bytes of the compressed images forces the user to hold all the bytes in memory or save them as duplicates so we can store a path instead of holding them in memory. In both scenarios, the file is a duplicate because the compression itself already created a file in the cache folder.

This is important if we compress multiple files. The current workflow: -> Select Images -> Compress -> Wait for the user to confirm compression and save to the device.

These lead to duplicate files and unnecessary storage usage if we don't want to hold the files in memory. To avoid the high memory usage, we only store a reference to the file path so we can wait for user input to permanently save the image at a permanent storage location.

ynnob avatar Jan 05 '24 20:01 ynnob