Reduce size of default compressed files, update README (#736)

This commit is contained in:
Phil Gebauer 2018-06-26 01:20:26 -07:00 committed by Ivan Pusic
parent d7bef85a32
commit ad5357b0a2
3 changed files with 5 additions and 5 deletions

View File

@ -100,7 +100,7 @@ ImagePicker.clean().then(() => {
| height | number | Height of result image when used with `cropping` option |
| multiple | bool (default false) | Enable or disable multiple image selection |
| writeTempFile (ios only) | bool (default true) | When set to false, does not write temporary files for the selected images. This is useful to improve performance when you are retrieving file contents with the `includeBase64` option and don't need to read files from disk. |
| includeBase64 | bool (default false) | Enable or disable returning base64 data with image |
| includeBase64 | bool (default false) | When set to true, the image file content will be available as a base64-encoded string in the `data` property. Hint: To use this string as an image source, use it like: ``<Image source={{uri: `data:${image.mime};base64,${(new Buffer(image.data)).toString('base64')}`}} />`` |
| includeExif | bool (default false) | Include image exif data in the response |
| cropperActiveWidgetColor (android only) | string (default `"#424242"`) | When cropping image, determines ActiveWidget color. |
| cropperStatusBarColor (android only) | string (default `#424242`) | When cropping image, determines the color of StatusBar. |
@ -117,7 +117,7 @@ ImagePicker.clean().then(() => {
| compressVideoPreset (ios only) | string (default MediumQuality) | Choose which preset will be used for video compression |
| compressImageMaxWidth | number (default none) | Compress image with maximum width |
| compressImageMaxHeight | number (default none) | Compress image with maximum height |
| compressImageQuality | number (default 1) | Compress image with quality (from 0 to 1, where 1 is best quality) |
| compressImageQuality | number (default 1 (Android)/0.8 (iOS)) | Compress image with quality (from 0 to 1, where 1 is best quality). On iOS, values larger than 0.8 don't produce a noticable quality increase in most images, while a value of 0.8 will reduce the file size by about half or less compared to a value of 1. |
| loadingLabelText (ios only) | string (default "Processing assets...") | Text displayed while photo is loading in picker |
| mediaType | string (default any) | Accepted mediaType for image selection, can be one of: 'photo', 'video', or 'any' |
| showsSelectedCount (ios only) | bool (default true) | Whether to show the number of selected assets |

View File

@ -72,7 +72,7 @@
NSNumber *compressQuality = [options valueForKey:@"compressImageQuality"];
if (compressQuality == nil) {
compressQuality = [NSNumber numberWithFloat:1];
compressQuality = [NSNumber numberWithFloat:0.8];
}
result.data = UIImageJPEGRepresentation(result.image, [compressQuality floatValue]);

View File

@ -82,7 +82,7 @@ RCT_EXPORT_MODULE();
@"waitAnimationEnd": @YES,
@"height": @200,
@"useFrontCamera": @NO,
@"compressImageQuality": @1,
@"compressImageQuality": @0.8,
@"compressVideoPreset": @"MediumQuality",
@"loadingLabelText": @"Processing assets...",
@"mediaType": @"any",
@ -560,7 +560,7 @@ RCT_EXPORT_METHOD(openCropper:(NSDictionary *)options
UIImage *imgT = [UIImage imageWithData:imageData];
NSNumber *compressQuality = [self.options valueForKey:@"compressImageQuality"];
Boolean isLossless = (compressQuality == nil || [compressQuality floatValue] == 1);
Boolean isLossless = (compressQuality == nil || [compressQuality floatValue] >= 0.8);
NSNumber *maxWidth = [self.options valueForKey:@"compressImageMaxWidth"];
Boolean useOriginalWidth = (maxWidth == nil || [maxWidth integerValue] >= imgT.size.width);