Skip to content

Commit

Permalink
save image width and height for android
Browse files Browse the repository at this point in the history
  • Loading branch information
parveshneedhoo committed Oct 24, 2023
1 parent 31e222c commit b428841
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/android/ImagePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
Expand Down Expand Up @@ -76,6 +77,7 @@ public boolean execute(String action, final JSONArray args, final CallbackContex

public void onActivityResult(int requestCode, int resultCode, Intent data) {
ExecutorService executor = Executors.newSingleThreadExecutor();
ArrayList<JSONObject> imageInfos = new ArrayList<>();
executor.execute(() -> {
try {
cordova.getActivity().runOnUiThread(() -> {
Expand Down Expand Up @@ -111,7 +113,17 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}
}
JSONArray res = new JSONArray(fileURIs);
for (int i=0; i<fileURIs.size(); i++) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Uri ImageUri = Uri.parse(fileURIs.get(i));
BitmapFactory.decodeFile(new File(ImageUri.getPath()).getAbsolutePath(), options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
JSONObject json = new JSONObject();
imageInfos.add(json);
}
JSONArray res = new JSONArray(imageInfos);
callbackContext.success(res);
} else if (resultCode == Activity.RESULT_CANCELED && data != null) {
String error = data.getStringExtra("ERRORMESSAGE");
Expand Down

0 comments on commit b428841

Please sign in to comment.