PHP-Code:
$path = '/my/path/'; // trailing slash!
function _w($w,$h)
{
if ($w > 800) {
$w = round($w/2);
$h = round($w/2);
}
return ' width="' . $w . '" height="'. $h .'" ';
}
$dir = dir($path);
while ($file = $dir->read()) {
$file = $path.$file;
if(is_dir($file)) continue;
$new = preg_replace(
'/\\swidth="?(\\d+)"?\\s+height="?(\\d+)"?/ie',
'_w(\\\\1,\\\\2)',
implode('', file($file))
);
$fh = fopen($file, 'w');
fputs($fh, $new);
fclose($fh);
}
Ähnlich in Perl, wahrscheinlich etwas kürzer...
~