PHP-Code: <?php //Verzeichnis durchsuchen und filtern $h = opendir('.'); while ($file = readdir($h)) { $img = false; $png = false; $img = false; if (eregi('.png$', $file)) { $img = ImageCreateFromPNG($file); $png = true; $im = true; } elseif (eregi('.jpg', $file)) { $img = ImageCreateFromJPEG($file); $im = true; } if ($im) { print('Wandle ' . $file . ' um.<br />'); $alt_breite = imagesx($img); $alt_hoehe = imagesy($img); $neu_breite = 640; //Durch die Breite ersetzen $neu_hoehe = round(($alt_hoehe / $alt_breite) * 100); $thumb = imagecreate($neu_breite, $neu_hoehe); imagecopyresized($thumb, $img, 0, 0, 0, 0, $neu_breite, $neu_hoehe, $alt_breite, $alt_hoehe); if ($png) imagePNG($img, 'thumb-' . $file); else imageJPEG($img, 'thumb-' . $file); imagedestroy($img); $img = false; } } ?> Jetzt gehts auch mit jpg. Ähm... und du musst den Ordner für PHP schreibbar machen.
<?php //Verzeichnis durchsuchen und filtern $h = opendir('.'); while ($file = readdir($h)) { $img = false; $png = false; $img = false; if (eregi('.png$', $file)) { $img = ImageCreateFromPNG($file); $png = true; $im = true; } elseif (eregi('.jpg', $file)) { $img = ImageCreateFromJPEG($file); $im = true; } if ($im) { print('Wandle ' . $file . ' um.<br />'); $alt_breite = imagesx($img); $alt_hoehe = imagesy($img); $neu_breite = 640; //Durch die Breite ersetzen $neu_hoehe = round(($alt_hoehe / $alt_breite) * 100); $thumb = imagecreate($neu_breite, $neu_hoehe); imagecopyresized($thumb, $img, 0, 0, 0, 0, $neu_breite, $neu_hoehe, $alt_breite, $alt_hoehe); if ($png) imagePNG($img, 'thumb-' . $file); else imageJPEG($img, 'thumb-' . $file); imagedestroy($img); $img = false; } } ?>
--Auf meiner Homepage gibt es unter anderem ein PHP-Tutorial!Was man mit CSS alles anstellen kann Opera rulez! opera.com - opera-info.de - Opera- Skins, Banner, Einstellungen und vieles mehr -- Windows 9x/ME A thirty-two bit extension and GUI shell to a sixteen bit patch to an eight bit operating system originally coded for a four bit microprocessor and sold by a two-bit company that can't stand one bit of competition.
Foren-Regeln