json - convert image 64X64 px after decoding base64 image in php -
hi retriving base64 encoded version of image , have stored cropping small size. not able crop image please me code follow.. please me in cropping base 64 image
$data = str_replace('data:image/png;base64,', '', $note['file']); $data = str_replace(' ', '+', $data); $decodedfile = base64_decode($data); $file = fopen($destination , 'wb'); if(!fwrite($file, $decodedfile)){ //return("error: can't save file $destination"); return '-1'; } fclose($file);
you can use gd library create image file binary code:
function binarytofile($binary_imagen, $width, $height, $new_name, $url_destiny) { try{ //actual size $info = getimagesizefromstring($binary_imagen); $old_width = $info[0]; $old_height = $info[1]; //new resource $resource = imagecreatefromstring($binary_imagen); $resource_copy = imagecreatetruecolor($width, $height); imagealphablending( $resource_copy , false ); imagesavealpha( $resource_copy , true ); imagecopyresampled($resource_copy, $resource, 0, 0, 0, 0, $width, $height, $old_width, $old_height); $url = $url_destiny."/".$new_name".png"; $final = imagepng($resource_copy, $url, 9); imagedestroy($resource); imagedestroy($resource_copy); return 1; }catch (exception $e) { return 0; } }
Comments
Post a Comment