PHP functions containing imagick stop working after a while?
Posted: 2011-04-10T12:25:19-07:00
Hello all,
I've been a user of the Imagick PHP class for about 6 months now and i've implemented it in multiple Image altering functions across my project. Last week one of my functions, which simply equalizes the image using equalizeImage and then echo's the image out, stopped working. In all browsers it just returned a blank page, however when I echo'd out the image without a header('content-type: image/jpeg') it returned what looks to be the raw image. There were no errors displayed whatsoever (all my PHP errors are on) and I hadn't touched the code for the functions in weeks because it had been in use and working fine for that period of time. Since I'm using a MVC framework (cakePHP) I moved the function into another controller (another file) and tried to equalise the image again with the page returning blank. I managed to fix it eventually by moving the function into yet another file but I couldn't find the cause of the problem.
Today the same equalise function in the new file is producing this strange blank output again but to my dismay another function which echo's out a watermarked image to the page is doing the EXACT same thing (this function was working fine when the equalise function died the first time) I can't figure out whats causing the problem!
I have a variety of other functions which create thumbnails and then write them to directories on my server and these seem to work absolutely fine (for now) but when it comes to echoing out an image (not saving it anywhere) the output seems to be corrupt jpegs
This is simply the code for my function:
What I don't understand is, these functions have been working fine for the past 2 weeks (used daily at least 50 times) and all of a sudden they just stop working? Imagick is still working on other parts of the application though.
Thanks in advance,
Jordan
I've been a user of the Imagick PHP class for about 6 months now and i've implemented it in multiple Image altering functions across my project. Last week one of my functions, which simply equalizes the image using equalizeImage and then echo's the image out, stopped working. In all browsers it just returned a blank page, however when I echo'd out the image without a header('content-type: image/jpeg') it returned what looks to be the raw image. There were no errors displayed whatsoever (all my PHP errors are on) and I hadn't touched the code for the functions in weeks because it had been in use and working fine for that period of time. Since I'm using a MVC framework (cakePHP) I moved the function into another controller (another file) and tried to equalise the image again with the page returning blank. I managed to fix it eventually by moving the function into yet another file but I couldn't find the cause of the problem.
Today the same equalise function in the new file is producing this strange blank output again but to my dismay another function which echo's out a watermarked image to the page is doing the EXACT same thing (this function was working fine when the equalise function died the first time) I can't figure out whats causing the problem!
I have a variety of other functions which create thumbnails and then write them to directories on my server and these seem to work absolutely fine (for now) but when it comes to echoing out an image (not saving it anywhere) the output seems to be corrupt jpegs
This is simply the code for my function:
Code: Select all
$image = new Imagick($image_path);
$image->equalizeImage();
header('content-type: image/jpeg');
echo $image;
die();
Thanks in advance,
Jordan