Thumbnails erstellen (GD-Lib 2.0)
Dieses Script erstellt ein Thumbnail! Es funktioniert aber
bloss mit GD-Lib 2.0 oder höher
|
Script: |
<?php
function createThumb($img_src,
$img_width ,
$img_height,
$des_src)
{
$im
= imagecreatefromjpeg($img_src);
list($src_width,
$src_height)
= getimagesize($img_src);
if($src_width
>= $src_height)
{
$new_image_width
= $img_width;
$new_image_height
= $src_height
* $img_width
/ $src_width;
}
if($src_width
< $src_height)
{
$new_image_height
= $img_width;
$new_image_width
= $src_width
* $img_height
/ $src_height;
}
$new_image
= imagecreatetruecolor($new_image_width,
$new_image_height);
imagecopyresampled($new_image,
$im, 0,
0, 0,
0, $new_image_width,$new_image_height,
$src_width,
$src_height);
imagejpeg($new_image,
$des_src. "/"
.$img_src,
100);
}
$file =
"linux.jpg";
$groesse =
"100";
createThumb($file,
$groesse, $groesse,
"thumbnails");
echo "<a href=".$file."
target=_blank><img src=thumbnails/".$file."
border=0></a>";
?>
|
|