Ciao a tutti,
ho questo utilissimo script per la creazione al volo di miniature di foto, solo che funziona solo con le jpeg, se volessi farla funzionare anche per le altre estensioni gif, png e bmp, come posso fare?
Codice PHP:<?php
$im = $_GET['im'];
$maxsize = $_GET['maxsize'];
if ($maxsize == '') {
$image = exif_thumbnail($im, $width, $height, $type);
if ($image) {
header('Content-type: ' .image_type_to_mime_type($type));
print $image;
}
else {
print 'No thumbnail available';
}
} else {
$filename = $im;
$width = $maxsize;
$height = $maxsize;
header('Content-type: image/jpeg');
list($width_orig, $height_orig) = getimagesize($filename);
if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_orig;
}
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p);
imagedestroy($image);
imageDestroy($image_p);
}

Rispondi quotando