0

I have to upload a picture to a server. But, after the upload, the photo gets resized.

This is what I am doing :

 private void clickpic() {
        // Check Camera
        if (getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
            // Open default camera
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
            // start the image capture Intent
            startActivityForResult(intent, 100);
        } else {
            Toast.makeText(getApplication(), "Nie ma dostępu do aparatu !", Toast.LENGTH_LONG).show();
        }
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 100 && resultCode == RESULT_OK) {
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            selectedImage = data.getData();
            photo = (Bitmap) data.getExtras().get("data");

            // Cursor to get image uri to display

            String[] filePathColumn = {MediaStore.Images.Media.DATA};
            Cursor cursor = getContentResolver().query(selectedImage,
                    filePathColumn, null, null, null);
            cursor.moveToFirst();
            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            picturePath = cursor.getString(columnIndex);
            cursor.close();




//            photo.compress(Bitmap.CompressFormat.JPEG, 100, stream);

            bm = BitmapFactory.decodeFile(picturePath);

            imageInByte = stream.toByteArray();
            lengthbmp = imageInByte.length;
            width = (short) photo.getWidth();
            height = (short) photo.getHeight();
            showToast(width + " " + height + "  " );
            imageView.setImageBitmap(photo);

//            resizeBm = Image.resizeBitmap(picturePath,Config.resizeWidth , Config.resizeHeight);


        }
    }
AxelH
  • 14,325
  • 2
  • 25
  • 55
Krzysztof Pokrywka
  • 1,356
  • 4
  • 27
  • 50
  • I am quite surprise you get anything in the Stream since the line is commented. I didn't see the "Send to server" part – AxelH Nov 16 '16 at 13:23
  • Possible duplicate of [android taking picture by MediaStore.ACTION\_IMAGE\_CAPTURE - specifying image size](http://stackoverflow.com/questions/9500781/android-taking-picture-by-mediastore-action-image-capture-specifying-image-siz) – nandsito Nov 16 '16 at 13:23
  • From what I remember doing last year. You just need to send the picture into a `Byte[]` and rebuild the file on the other end. Compare the size of the files to see if there is a difference. – AxelH Nov 16 '16 at 13:26
  • @AxelH Could you explain me how I can do this ? – Krzysztof Pokrywka Nov 16 '16 at 13:28
  • [To send a picture](http://stackoverflow.com/questions/20322528/uploading-images-to-server-android). But this doesn't answer you question about this resizing. From what I can see, this is not in this code. Check both sides file contains. If there is a difference. Might be from the reception on the server !! – AxelH Nov 16 '16 at 13:32
  • @AxelH But when I check a size Bitmap which i created from photo I see resize value – Krzysztof Pokrywka Nov 16 '16 at 13:37
  • I don't have time to write an answer (and no environnement for Android) but there is a nice [tutorial](http://www.codepool.biz/take-a-photo-from-android-camera-and-upload-it-to-a-remote-php-server.html) to follow – AxelH Nov 16 '16 at 13:42
  • @AxelH ok but in this toturial is anser for my question why I have thumbnail and I have question how I can get a normal photonot a thumbnail : This return a thumbnail protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 0 && resultCode == RESULT_OK) { Bundle extras = data.getExtras(); Bitmap imageBitmap = (Bitmap) extras.get("data"); mImageView.setImageBitmap(imageBitmap); } } – Krzysztof Pokrywka Nov 16 '16 at 13:49
  • Read more ... for better quality. I will try to post an answer in few hours (when I will be back home) If you can wait. – AxelH Nov 16 '16 at 13:50
  • `But, after the upload, the photo gets resized. `. So it is uploaded. And all is ok. And then the next day it get s resized? By who? Pretty unclear post. – greenapps Nov 16 '16 at 13:56
  • And what do you consider to be resized? Please tell resolution( WxH) before and after. Or do you mean the size of the jpg file? Please give exact numbers. – greenapps Nov 16 '16 at 13:58
  • @greenapps when I create a Bitmap from this : bm = BitmapFactory.decodeFile(picturePath); I get a the Thumbnail but I want to get a normal photo – Krzysztof Pokrywka Nov 16 '16 at 14:12
  • You did noyt answer my questions. Why not? And you should post the code that uploads the image. – greenapps Nov 16 '16 at 16:56

0 Answers0