Größe ändern Bild-aus Datei

Bin ich das hochladen eines Bildes auf einen server, und bevor das passiert, würde ich mag, um die Größe der image-Dimensionen. Ich bekomme das Bild mit einem URI wie diese:

Constants.currImageURI = data.getData();

dies ist der Aufruf zum hochladen des Bildes:

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 "";
}

Gibt es eine Möglichkeit, um die Größe der Datei basierend auf pixel-Dimensionen?

Dank.

InformationsquelleAutor coder | 2011-12-07

Schreibe einen Kommentar