base64 to image
import base64
file = 'deer.jpg'
image = open(file, 'rb')
image_read = image.read()
image_64_encode = base64.encodebytes(image_read) #encodestring also works aswell as decodestring
print('This is the image in base64: ' + str(image_64_encode))
image_64_decode = base64.decodebytes(image_64_encode)
image_result = open('deer_decode.jpg', 'wb') # create a writable image and write the decoding result
image_result.write(image_64_decode)
$path = 'myfolder/myimage.png';
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
Also in PHP:
- array only get duplicates
- current date to timestamp php
- 413 error laravel
- artisan composer install
- convert lowercase to uppercase php
- add user role to wp admin page css
- create folder php en linux centos 7
- check array item exists php
- find key in arrray php
- composer update php mbstring.so missing
- ->with('success'
- csv to json php
- <?php function webmull($webmull) { switch ($webmull) { case 'e': print('5'); break; case 'm': echo('6'); break; case 'b': continue; break; default: echo '7'; break; } } webmull('w'); webmull('e'); webmull('b'); webmull('m'); ?>
- auto generate password in php
- current time not current date php
- bu7scador con laravel
- errorLevel php no warnings
- convert to timestamp php
- date / time formatter php
- associative array rev in php
- PHP DATE 2019-10-01 FORMAT
- ErrorException Allowed memory size of 536870912 bytes exhausted (tried to allocate 400560128 bytes)
- dat day in php
- catch custom exception php