I am manipulating images with js, and I'd like to save these transformed images. I'm posting this data with ajax:
image : canvas.toDataURL('image/jpeg')
This way, I get the base64 code for the image, but I can't find a way to read it with Imagick.
This is my process:
$img = new Imagick();
$decoded = base64_decode($_POST['image']);
$img->readimageblob($decoded);
But this fails:
Fatal error: Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `' @ error/blob.c/BlobToImage/360' in /Library/WebServer/Documents/test/save.php:7 Stack trace:
#0 /Library/WebServer/Documents/test/save.php(7): Imagick->readimageblob('u?Z?f?{??z?????...')
Any ideas why?
Figured out.
I had to remove the data:image/png;base64,
part from the posted string, and then imagick could interpret it as blob.