Skip to content

Commit

Permalink
[Android] Using inJustDecodeBounds when decoding file
Browse files Browse the repository at this point in the history
  • Loading branch information
ivpusic committed Jul 30, 2016
1 parent e7927f7 commit b5f6acf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions android/src/main/java/com/reactnative/picker/PickerModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,19 @@ private WritableMap getImage(Uri uri, boolean resolvePath) {
}

BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;

long fileLen = 0;
if (path != null) {
fileLen = new File(path).length();
}

Bitmap bitmap = BitmapFactory.decodeFile(path, options);
BitmapFactory.decodeFile(path, options);
image.putString("path", "file://" + path);
image.putInt("width", options.outWidth);
image.putInt("height", options.outHeight);
image.putString("mime", options.outMimeType);

if (bitmap != null) {
image.putInt("size", (int)fileLen);
bitmap.recycle();
} else {
image.putInt("size", 0);
}
image.putInt("size", (int)fileLen);

return image;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-image-crop-picker",
"version": "0.5.2",
"version": "0.5.3",
"description": "Select single or multiple images, with croping option",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit b5f6acf

Please sign in to comment.