10-25-2007, 02:44 PM
|
#3 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
Here's a bit of code for the image part. It could be cleaned up a bit better, but it's enough to get your started and it works (currently only with jpeg)
PHP Code:
<?php
$szImagesDir = 'images/'; $szThumbsDir = 'images/thumbs/';
foreach (glob($szImagesDir . '*.{jpg,JPG}', GLOB_BRACE) as $szImagePath) { $aImagePathParts = explode('/', $szImagePath); $szFileName = end($aImagePathParts);
if (!file_exists($szThumbsDir . $szFileName)) { $pImageHandle = imagecreatefromjpeg($szImagePath);
if (!$pImageHandle) { continue; }
$aSize = getimagesize($szImagePath); $pNewImageHandle = imagecreatetruecolor(64, 64); imagecopyresampled($pNewImageHandle, $pImageHandle, 0, 0, 0, 0, 64, 64, $aSize[0], $aSize[1]); imagejpeg($pNewImageHandle, $szThumbsDir . $szFileName); } echo '<img src="' . $szThumbsDir . $szFileName . '" />'; }
?>
Simply change the two directory paths at the top to point to your images and thumb folders. The thumbs folder is used to store thumbnails of each image - you'll need to create this.
Hope it helps.
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
|
|
|
|