Error when using readImageBlob
Posted: 2013-05-09T01:05:56-07:00
Hello,
I'm creating a image using HTML canvas and I upload it into a php script. However, if the image dimensions are too big, I got the following error message:
"Zero size image string passed". But I'm not sure what is the limitation... How can I increase the max image width and height if this is the issue ?
Here is my code:
1) Convert the canvas to a data string (javascript code)
then I upload the data using jquery $.post()
2) My PHP script to receive the image string and create the file
I'm using imagick (3.1.0RC2 ) with image magick (6.6.0-4)
Thank you for your help
I'm creating a image using HTML canvas and I upload it into a php script. However, if the image dimensions are too big, I got the following error message:
"Zero size image string passed". But I'm not sure what is the limitation... How can I increase the max image width and height if this is the issue ?
Here is my code:
1) Convert the canvas to a data string (javascript code)
Code: Select all
var dataURL = canvas.toDataURL({format:"jpeg", quality:0}),
strDataURI = dataURL.substr(dataURL.indexOf(',')+1);
2) My PHP script to receive the image string and create the file
Code: Select all
$data = base64_decode($_POST["data"]);
$folder = "images/";
$filename = uniqid(rand(), true);
$ext = ".jpg";
$filepath = $folder.$filename.$ext;
$image = new Imagick();
$image->setCompression(Imagick::COMPRESSION_JPEG);
$image->setCompressionQuality(90);
$image->setFormat('jpg');
if($image->readImageBlob($data)) {
$image->setImageFormat('jpg');
$image->writeImage($filepath);
$image->clear();
$image->destroy();
// Do stuff with $filepath
}
I'm using imagick (3.1.0RC2 ) with image magick (6.6.0-4)
Thank you for your help