decode base64 image php
base64_decode('base64');$path = 'myfolder/myimage.png';
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
function base64_to_jpeg($base64_string, $output_file) {
// open the output file for writing
$ifp = fopen( $output_file, 'wb' );
// split the string on commas
// $data[ 0 ] == "data:image/png;base64"
// $data[ 1 ] == <actual base64 string>
$data = explode( ',', $base64_string );
// we could add validation here with ensuring count( $data ) > 1
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
// clean up the file resource
fclose( $ifp );
return $output_file;
}
Also in PHP:
- check array key exists php js
- date( d ) in php
- How to Redirect Website to a Mobile Version when Accessed on a Mobile Device
- convert php string to uppercase
- create seeds laravel
- datetformat php
- display php errors on page
- create random password with refresh in php
- date now php different
- Target class [Barryvdh\Cors\HandleCors] does not exist.
- base encode64 php
- console log data php
- add one day to date('l') php
- delete register option laravel 7
- array_unique() on value php
- check if key of array key true or false foreach php
- create a seeder in laravel
- cache resource laravel
- count characters string php
- There is no extension able to load the configuration for "_translation_webui"
- declare empty array php
- Backend fatal error: PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted in laravel 8
- find character php
- date( ) php