hui-z / image_gallery_saver

flutter中用于保存图片到相册的Plugin
MIT License
275 stars 377 forks source link

saveImage() changes the image size #281

Open antontishkov opened 9 months ago

antontishkov commented 9 months ago

Steps to reproduce the issue

  1. Find any any large image on Unsplash. For example, the chosen image size is 8mb.
  2. Read this image using http.readBytes(). The size of your Uint8List will be exactly the same: 8 mb.
  3. Save this image to iOS gallery. The size of exported image will be different. 9.7 mb in my case.
Code sample ```dart Future runTest() async { const String imageUrl = 'https://unsplash.com/photos/A5rCN8626Ck/download?ixid=M3w0NDczMDZ8MHwxfHNlYXJjaHwzfHx0cmF2ZWx8ZW58MHx8fHwxNzA0MTEzNzkxfDA'; // When I save this image to my laptop, the size is 8 007 600 bytes. final Uint8List bytes = await http.readBytes(Uri.parse(imageUrl)); print('Bytes length: ${bytes.length}'); // "flutter: Bytes length: 8007600" // The size is exactly the same! await ImageGallerySaver.saveImage(bytes, quality: 100); // After that the image size changed significantly: 9.7 mb. } ```

Why the saveImage() method changes the image size? Flutter writeAsBytes() method on the other hand doesn't change it.