【发布时间】:2019-09-18 09:48:17
【问题描述】:
我正在使用以下代码来选择具有 maxHeight/width 的图像以节省空间。
void openGallery()async {
var gallery = await ImagePicker.pickImage(
source: ImageSource.gallery,
maxHeight: maxImageSize,
maxWidth: maxImageSize,
);
if (gallery!=null) {
var bytes = await gallery.readAsBytes();
if (DEBUG) print('Image bytes: ${bytes.length / 1024} KB');
if (DEBUG) print('Image path: ${gallery.path}');
setState(() {
List<int> imageBytes = gallery.readAsBytesSync();
_imageB64 = base64Encode(imageBytes);
// decoded = base64Decode(_imageB64);
if (DEBUG) print('Base64 String length: ${_imageB64.length / 1024} KB');
});
}
}
我在控制台中收到以下警告:
image_picker: compressing is not supported for type (null). Returning the image with original quality
flutter: Image bytes: 153.583984375 KB
flutter: Image path: ...myimagpath.jpg
flutter: Base64 String length: 204.78125 KB
1) 一方面,我可以看到我的图像缩小了,因为它只有 200kB,但另一方面,第一行让我感到困惑。
2) 另外,我的印象是 BASE64 编码的图像尺寸变小了,因为我想将它们保存到 Firebase,将它们保存为“字节”(因为它是 153kb)会不会有问题?
【问题讨论】:
标签: flutter dart flutter-dependencies dart-pub