3 * On the fly Thumbnail generation.
4 * Creates thumbnails given by thumbs.php?img=/relative/path/to/image.jpg
5 * relative to the base_dir given in config.inc.php
6 * @author $Author:ray $
7 * @version $Id:thumbs.php 677 2007-01-19 22:24:36Z ray $
8 * @package ImageManager
11 require_once('config.inc.php');
12 require_once('Classes/ImageManager.php');
13 require_once('Classes/Thumbnail.php');
15 //check for img parameter in the url
16 if(!isset($_GET['img']))
22 $manager = new ImageManager($IMConfig);
24 //get the image and the full path to the image
25 $image = rawurldecode($_GET['img']);
26 $fullpath = Files
::makeFile($manager->getImagesDir(),$image);
29 if(!is_file($fullpath))
34 $imgInfo = @getImageSize
($fullpath);
36 //Not an image, send default thumbnail
37 if(!is_array($imgInfo))
39 //show the default image, otherwise we quit!
40 $default = $manager->getDefaultThumb();
43 header('Location: '.$default);
47 //if the image is less than the thumbnail dimensions
48 //send the original image as thumbnail
50 if ($imgInfo[0] <= $IMConfig['thumbnail_width']
51 && $imgInfo[1] <= $IMConfig['thumbnail_height'])
54 header('Location: '. $manager->getFileURL($image));
58 //Check for thumbnails
59 $thumbnail = $manager->getThumbName($fullpath);
61 if(is_file($thumbnail))
63 //if the thumbnail is newer, send it
64 if(filemtime($thumbnail) >= filemtime($fullpath))
66 header('Location: '.$manager->getThumbURL($image));
72 $thumbnailer = new Thumbnail($IMConfig['thumbnail_width'],$IMConfig['thumbnail_height']);
73 $thumbnailer->createThumbnail($fullpath, $thumbnail);
75 //Check for NEW thumbnails
76 if(is_file($thumbnail))
78 //send the new thumbnail
79 header('Location: '.$manager->getThumbURL($image));
84 //show the default image, otherwise we quit!
85 $default = $manager->getDefaultThumb();
88 header('Location: '.$default);