My first guess would be that the http request for the image is failing for some reason (maybe timing out?). If you save that image to your web host and then access it via the file system (instead of http), do you still have that problem?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
btw it works 100% of the time if the script doesn't have imagick::blurImage() in it
My scripts never had a problem with that method before. Do you think it's a bug in ImageMagic? However if that's the case, I'm confused, because my host says they haven't updated ImageMagick since last year.
Last edited by evenstar7139; 01-14-2013 at 10:49 AM.
The better I get at programming, the more I appreciate arrays. Handy dandy things they are.
Try adding a call to set_time_limit() (arg of 0 for no time limit or else a large number of seconds) to see if it's simply PHP timing out?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Added set_time_limit(0); to the beginning of the script and I'm still getting intermittent the error. Same thing happened with set_time_limit(5000000000000);
PHP Code:
<?php set_time_limit(0); $image = new Imagick('/home/mywebsitename/public_html/images/bordercollie25.jpg');
$image->blurImage(5,3); print "success"; ?>
Did I do it right? If so, what should I try next?
Last edited by evenstar7139; 01-14-2013 at 04:29 PM.
The better I get at programming, the more I appreciate arrays. Handy dandy things they are.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Tried that, nothing changed. When it fails I get a 500 internal server error and nothing else.
Something I noticed, though: When it's going to work, the script finishes quickly; when it's not, it spins its wheels for a few seconds and then I get the 500 error.
Anyhoo, do you think my host is at fault? Is there anything they could have done to cause this? I asked them about it and they're swearing up and down it's not them, and that it's my code, but I dunno...I have scripts whose code I haven't touched in a month that worked fine until a couple days ago =\
The better I get at programming, the more I appreciate arrays. Handy dandy things they are.
Outside of grepping the server logs to see what they say, I'm wondering if it could be some sort of file locking problem. You could try sticking in an $image->destroy(); once you're done with that object, just in case. (I'm at the straw-grasping stage here, so I'm not horribly optimistic.)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
It would be different than the php-errors.log or whatever it's called. This would be the web server (Apache, IIS, whatever) http error log, which you may or may not have access to depending on your hosting plan.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Well, I have multiple error logs. Could it be the one called main error log? I checked it right after seeing my script fail.
I saw a bunch of these:
[Mon Jan 14 19:43:38 2013] [warn] child process 13567 still did not exit, sending a SIGTERM
[Mon Jan 14 19:43:38 2013] [warn] child process 27344 still did not exit, sending a SIGTERM
[Mon Jan 14 19:43:38 2013] [warn] child process 27156 still did not exit, sending a SIGTERM
[Mon Jan 14 19:43:38 2013] [warn] child process 32016 still did not exit, sending a SIGTERM
[Mon Jan 14 19:43:38 2013] [warn] child process 14128 still did not exit, sending a SIGTERM
Then a bunch of these:
[Mon Jan 14 19:43:40 2013] [error] child process 27947 still did not exit, sending a SIGKILL
[Mon Jan 14 19:43:40 2013] [error] child process 27722 still did not exit, sending a SIGKILL
[Mon Jan 14 19:43:40 2013] [error] child process 23565 still did not exit, sending a SIGKILL
[Mon Jan 14 19:43:40 2013] [error] child process 24969 still did not exit, sending a SIGKILL
[Mon Jan 14 19:43:41 2013] [notice] caught SIGTERM, shutting down
This was the last line:
[Mon Jan 14 19:43:41 2013] [internal] (7614) httpd - error_log SIGTERM Received
- - - -
Ran the script again, got the error, and the log looked totally different. This was the only noteworthy thing I saw:
[Mon Jan 14 19:47:35 2013] [error] [client MY IP HERE] Premature end of script headers: js_test.php
That's the script I was running.
Last edited by evenstar7139; 01-14-2013 at 09:00 PM.
The better I get at programming, the more I appreciate arrays. Handy dandy things they are.
Try adding this right after you instantiate $image:
PHP Code:
$image->setResourceLimit(6, 1); // set max threads to 1
If that fixes it, I've earned my salary for the day. (If not, I'm about ready to give up. )
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Progress! I ran the test script 200 times and it didn't fail. However, when I started running my actual image generator, it got the error on the 3rd try.
Shall I email you the code? I don't want to post it here because sombody might rip it off :P
The better I get at programming, the more I appreciate arrays. Handy dandy things they are.
...anywhere else in the script? If so, in each case, you'll probably have to follow it up with the same setResourceLimit() on each new such object. Otherwise we'll "talk" tomorrow (already past my bedtime)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks