Tôi đang tải hình ảnh lên máy chủ và trước khi điều đó xảy ra, tôi muốn thay đổi kích thước kích thước hình ảnh. Tôi có được hình ảnh với một URI
như thế này:thay đổi kích thước hình ảnh từ tập tin
Constants.currImageURI = data.getData();
này được gọi để tải lên hình ảnh:
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 "";
}
Có cách nào để thay đổi kích thước tập tin dựa trên kích thước pixel?
Cảm ơn.