udsnit af gif billeder
Hej.Jeg har følgende script fra www.php.net, som lige nu kun kan klare jpg billeder. Hvordan får jeg det til at kunne klare gif billeder og andre formater ??? :
<?php
// The file
$filename = "/customers/sti.dk/sti.dk/httpd.www/test/".$_GET['filnavn'];
$percent = 0.5; // if you want to scale down first
$imagethumbsize = 50; // thumbnail size (area cropped in middle of image)
// Content type
//header('Content-type: image/jpeg');
// Get new dimensions
list($width, $height) = getimagesize($filename);
if ($width<100 or $height<100) {
$new_width = $width ;
$new_height = $height ; }
else {
$new_width = $width * $percent;
$new_height = $height * $percent; }
// Resample
$image_p = imagecreatetruecolor($imagethumbsize , $imagethumbsize); // true color for best quality
$image = imagecreatefromjpeg($filename);
// basically take this line and put in your versin the -($new_width/2) + ($imagethumbsize/2) & -($new_height/2) + ($imagethumbsize/2) for
// the 2/3 position in the 3 and 4 place for imagecopyresampled
// -($new_width/2) + ($imagethumbsize/2)
// AND
// -($new_height/2) + ($imagethumbsize/2)
// are the trick
imagecopyresampled($image_p, $image, -($new_width/2) + ($imagethumbsize/2), -($new_height/2) + ($imagethumbsize/2), 0, 0, $new_width , $new_width , $width, $height);
// Output
imagejpeg($image_p, null, 100);
?>
