sorry about that. i was typing this thing half asleep and i forgot quotation

here's fixed version:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body onload="reload()">
<?php
//configuration
//directory with original images
$in_dir = 'pics';
//directory for resized images
$out_dir = 'resized';
//target canve's size
$size = '800x800';
//how many pics to process in one run.
//keep it rather low to avoid timeouts
//(it will re-run itself as many times as needed anyways)
$limit = 2;
if(!is_dir($in_dir)){
die('wrong input directory!</body>');
}
if(!is_dir($out_dir)){
die('wrong output directory!</body>');
}
if(!file_put_contents($out_dir . '/__writetest', '1')){
die('can\'t write to output directory. check permissions!</body>');
}else{
unlink($out_dir . '/__writetest');
}
$files = glob($in_dir . '/*');
$i = 0;
$ii = 0;
while(isset($files[$i])){
if(preg_match('/.+(png|jpg|jpeg|gif|bmp|pcx)/i', basename($files[$i]))){
if(!file_exists($out_dir . '/' . basename($files[$i])) && $ii < $limit){
$file1 = $files[$i];
$file2 = $out_dir . '/' . basename($files[$i]);
$command = 'convert "' . $file1 . '" -resize ' . $size . ' -size ' . $size . ' xc:white +swap -gravity center -composite "' . $file2 . '"';
shell_exec($command);
echo 'Resized ' . $files[$i] . ' and saved as ' . $file2 . '<br />';
$ii++;
}
}
$i++;
}
echo '<br /><br /><noscript>reload to proccess next images</noscript>';
echo '<script language="javascript">' . "\n";
echo 'function reload(){' . "\n";
if($ii > 0){
echo 'window.location = \'' . $_SERVER['PHP_SELF'] . '?rand=' . rand(0, 999999999999) . '\';' . "\n";
}else{
echo 'alert(\'all pics resized\');' . "\n";
}
echo '}' . "\n";
echo '</script>' . "\n";
?>
</body>
</html>