I am uploading an image to a server and before that happens, I would like to resize the image dimensions. I get the image with a URI
like this:
Constants.currImageURI = data.getData();
this is the call to upload the image:
String response = uploadUserPhoto(new File(getRealPathFromURI(Constants.currImageURI)));
public String uploadUserPhoto(File image) {
DefaultHttpClient mHttpClient;
HttpParams params = new BasicHttpParams();
params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
mHttpClient = new DefaultHttpClient(params);
try {
HttpPost httppost = new HttpPost("http://myurl/mobile/image");
MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
multipartEntity.addPart("userID", new StringBody(Constants.userID));
multipartEntity.addPart("uniqueMobileID", new StringBody(Constants.uniqueMobileID));
multipartEntity.addPart("userfile", new FileBody(image, "mobileimage.jpg", "image/jpeg", "UTF-8"));
httppost.setEntity(multipartEntity);
HttpResponse response = mHttpClient.execute(httppost);
String responseBody = EntityUtils.toString(response.getEntity());
Log.d(TAG, "response: " + responseBody);
return responseBody;
} catch (Exception e) {
Log.d(TAG, e.getMessage());
}
return "";
}
Is there a way to resize the file based on pixel dimensions?
Thanks.