mardi 12 juillet 2016

Compress Bitmap image from android studio to jpeg in laravel

I received a Bitmap image from android studio from which I convert that image into an jpg file and upload it into a folder,by using this following code..

$image                  = $_REQUEST['avatar'];
$path = public_path()."/uploads/users/$_REQUEST['user_id'].jpg";
file_put_contents($path,base64_decode($image));

It works fine for me..But,

I need to compress that image before uploading it into the folder..

I tried like this way,but it doesn't work for me

            $quality = 90;

                $file = $image;
                $file_name      = $up_img.'.jpg';


                $file->move('uploads/users', $file_name);

                $src  = 'uploads/restaurants/'. $file_name;
                $img  = imagecreatefromjpeg($src);
                $dest = ImageCreateTrueColor(Input::get('w'),
                    Input::get('h'));

                imagecopyresampled($dest, $img, 0, 0, 0, 0, 100, 100, 100, 100);
                imagejpeg($dest, $src, $quality);

How should I do this..

Someone help me.. Thanks in advance..



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire