Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 5844f4b

Browse files
author
Jamie Halmick
committed
image_picker Lower JPEG quality to 50% to save on uploads
1 parent b0a4294 commit 5844f4b

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImageResizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private File resizedImage(String path, Double maxWidth, Double maxHeight) throws
8787
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
8888
boolean saveAsPNG = false; //bmp.hasAlpha(); // hardcode to JPEG so smaller files to upload - Jamie
8989
scaledBmp.compress(
90-
saveAsPNG ? Bitmap.CompressFormat.PNG : Bitmap.CompressFormat.JPEG, 70, outputStream); // lower quality of JPEG to 70 from 100 for smaller file size - Jamie
90+
saveAsPNG ? Bitmap.CompressFormat.PNG : Bitmap.CompressFormat.JPEG, 50, outputStream); // lower quality of JPEG to 50 from 100 for smaller file size - Jamie
9191

9292
String[] pathParts = path.split("/");
9393
String imageName = pathParts[pathParts.length - 1];

packages/image_picker/ios/Classes/FLTImagePickerMetaDataUtil.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ + (NSData *)convertImage:(UIImage *)image
6969

7070
switch (type) {
7171
case FLTImagePickerMIMETypeJPEG: {
72-
CGFloat qualityFloat = quality ? quality.floatValue : 0.7; // Jamie Halmick - hardcoded to 70% instead of 100% quality to save size
72+
CGFloat qualityFloat = quality ? quality.floatValue : 0.5; // Jamie Halmick - hardcoded to 50% instead of 100% quality to save size
7373
return UIImageJPEGRepresentation(image, qualityFloat);
7474
}
7575
case FLTImagePickerMIMETypePNG:
7676
return UIImagePNGRepresentation(image);
7777
default: {
7878
// converts to JPEG by default.
79-
CGFloat qualityFloat = quality ? quality.floatValue : 0.7; // Jamie Halmick - hardcoded to 70% instead of 100% quality to save size
79+
CGFloat qualityFloat = quality ? quality.floatValue : 0.5; // Jamie Halmick - hardcoded to 50% instead of 100% quality to save size
8080
return UIImageJPEGRepresentation(image, qualityFloat);
8181
}
8282
}

0 commit comments

Comments
 (0)