<?php
header('Content-type: image/jpeg');
$image = new Imagick("opossum.jpg");
$image->thumbnailImage(50, 0);
echo $image;
?>
This example gets every .jpg in a directory, makes thumbnails for them and use the thumbnail to link to the full image. To use it copy the text file and change the extension to thumbs.php. In the page you want to have the thumbnails add this line of code:
<?php include("thumbs.php"); ?>
<?php
$width = 200; # maximum width
$self = $_SERVER[PHP_SELF];
# if image submitted then make thumbnail
if ( $im = $_GET[im] )
{
header('Content-type: image/jpeg');
$image = new Imagick("$im");
$image->thumbnailImage($width, 0);
echo $image;
exit;
}
# find all .jpg's in current directory
foreach (glob("*.jpg") as $filename)
{
# make image links
echo "<a href=\"$filename\"><img src=\"$self?im=$filename\" width=\"$width\"></a> ";
}
?>
|
|
|