views:

409

answers:

2

So, my plan is to make small thumbnails of URL's with PHP and IECapt. IECapt works well, a nice command line tool, gets the full sized image of specified URL in 1 to 4 seconds. But my problem is to execute it trough PHP. This is the code I've trying to get working:

exec('IECapt.exe ' . escapeshellarg($URL) . ' ' . escapeshellarg($Filename))

$URL is of course the URL, and $filename is a simplified version of the URL.

Sometimes I get the IECapt to snap the image(trough PHP), but it takes awfully long (30-60s), and in the end I always get a 500-error, with no error messages to tell me what's wrong. Both variables are fine, they work manually with commandline:

IECapt http://google.com Google.png

My server set-up is IIS7 and PHP5.2.9, if relevant. (Windows Vista, all on my personal computer, so full access.)

Any ideas?

A: 

Probably the execution time is exceeded, and your script is killed. http://us3.php.net/manual/en/info.configuration.php#ini.max-execution-time

Once you are editing the configuration file, check also that error messages display is On, so they get to your screen (set display_errors to On)

Palantir
A: 

As Palantir says, it's exceeding the default PHP execution time. Any action that is likely to take a long time (i.e. over a few seconds) should not be run via PHP scripts in a web browser.

You need to write a CLI script (command line) to run these sort of actions asynchronously. CLI scripts have no limit on execution time by default.

See http://php.net/cli for more

If you're dong a lot of this kind of thing (i.e. having to process 100s of such actions) you should take a look at message queues which are designed to solve this sort of problem. See http://framework.zend.com/manual/en/zend.queue.html

The web browser is not the right place for heavy processing :)

simonrjones