I am using this code to convert a Bitmap to Base64:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, **quality**, baos);
byte[] b = baos.toByteArray();
base64code = Base64.encodeToString(b, Base64.DEFAULT);
and receiving it at the server side, this way:
$strImage = preg_replace('!\s*!', '', trim($this->input->post('image')));
$thefile = base64_decode($strImage);
$img = imagecreatefromstring($thefile);
//header('Content-Type: image/jpeg');
header('Content-Type: bitmap; charset=utf-8');
imagesavealpha($img, true);
imagejpeg($img,'./images/temp/testing.jpg',100);
imagedestroy($img);
Problem:
The actual image size which i am picking from the device gallery to send to the server is 344 kb When i set the quality = 0 and show a spinner dialog util the base64 string is being sent to the server it takes 5 secs to send, and the image received at the server side is 344 Kb but if i am setting quality = 100 it takes 60-70 secs to send, and the image i receive at the server side is 1.7 Mb
Question:
why am i getting the actual size when using quality = 0 and nearly 5 times bigger image when quality = 100
Note:
When i am setting the quality = 100 and change
imagejpeg($img,'./images/temp/testing.jpg',100);
to
imagejpeg($img,'./images/temp/testing.jpg',10);
it takes 60-70 secs to send but the image received on the server side is too small 67 Kb
Thank You