728x90
File? getResizeImage(File originalImage){
Image image = decodeImage(originalImage.readAsBytesSync())!;
int standard = 800;
int width = image.width;
int height = image.height;
double ratio = width/height;
Image? resizedImage;
if(ratio>1) resizedImage = copyResize(image, width: min(width, standard), height: min(width.toDouble()/ratio, standard.toDouble()/ratio).toInt());
else resizedImage = copyResize(image, width: min(width*ratio, standard*ratio).toInt(), height: min(height, standard).toInt());
File newFile = File(originalImage.path);
newFile.writeAsBytesSync(encodeJpg(resizedImage, quality: 95),);
return newFile;
}
728x90
'개발 > Flutter' 카테고리의 다른 글
tutorial_coach_mark flutter 튜토리얼 overlay touch (0) | 2022.03.24 |
---|---|
url_launcher 지도, 네비게이션 (0) | 2022.03.22 |
unfocus, keyboard down, focus 해제하고 싶을 때, 키보드 내리고 싶을 때 (0) | 2022.03.14 |
flutter 내부 db 중에 매우 빠르다는 hive (0) | 2022.03.07 |
Appbar back button color 변경 (0) | 2022.02.28 |