In my android application I Capture image or select image from gallery. then I encode that image in base64 string. then I send that image to PHP in JSON format or with normal post request. then I decode base64 string to PNG image and save on server. then save path of that image to mySQL image_url column.
This is the way I am currently working now..Which create image file.. but sometime it creates corrupt image file(full black or 0 KB or 20 KB in size). and Picasso does not work on such files. It shows decoder failed error of picasso.
This way reduces Image quality 1.5 MB image(on device) to 50 KB image (on server). my code for encoding to base64 is,
` // method for bitmap to base64
public static String encodeTobase64(Bitmap image) {
Bitmap immage = image;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
immage.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(b, Base64.DEFAULT);
return imageEncoded;
}`
If anyone have suggestions please help. or other way for sending and saving images.
EDITS are welcomed.