Hola amigos, lo que sucede es que el siguiente PHPScript redimenciona las imagenes gif pero les quita su animacion.
Lo que deseo es eliminar las lineas que le dicen al archivo que redimencione las imagenes con formato gif, no les quiero hacer nada.
Sin embargo deseo que las imagenes sean llamadas asi:
<img src="resize.php?imagen=photos/mifoto.jpg&w=300" width="300">
Pero, si el formato es gif no redimencione la imagen y la muestre igualita (para que no pierda su animacion)
<img src="resize.php?imagen=photos/mifoto.gif&w=300" width="300">
resize.php
Código PHP:
<?php
// IMG redimensionador (Héctor S. > [email protected])
//////////////////////////////////////////////////////////////////////////
if(file_exists($_GET["imagen"])){
$fotoperf = $_GET["imagen"];
header("Content-type: image/jpeg");
$fileextsp = split("/",$fotoperf);
$count = count($fileextsp) - 1;
$nomarch = $fileextsp[$count];
$fileext2 = pathinfo($nomarch);
$formatperf = strtolower($fileext2["extension"]);
$getsizesperf = getimagesize($fotoperf);
$widthf = $_GET["w"];
if($_GET["h"] == ""){
$h2 = $widthf * $getsizesperf[1];
$h2 = $h2 / $getsizesperf[0];
$heightf = $h2;
}else{
$heightf = $_GET["h"];
}
if($formatperf == "jpg" || $formatperf == "jpeg"){ $imgperf = imagecreatefromjpeg($fotoperf); }
if($formatperf == "gif"){ $imgperf = imagecreatefromgif($fotoperf); }
if($formatperf == "png"){ $imgperf = imagecreatefrompng($fotoperf); }
if($formatperf == "bmp"){ $imgperf = imagecreatefrombmp($fotoperf); }
if($getsizesperf[1] > $getsizesperf[0]){
$newheightperf = $widthf * $getsizesperf[1];
$newheightperf = $newheightperf / $getsizesperf[0];
$newwidthperf = $widthf;
if($newheightperf < $heightf){
$newwidthperf = $heightf * $getsizesperf[0];
$newwidthperf = $newwidthperf / $getsizesperf[1];
$newheightperf = $heightf;
}
}else{
$newwidthperf = $heightf * $getsizesperf[0];
$newwidthperf = $newwidthperf / $getsizesperf[1];
$newheightperf = $heightf;
if($newwidthperf < $widthf){
$newheightperf = $widthf * $getsizesperf[1];
$newheightperf = $newheightperf / $getsizesperf[0];
$newwidthperf = $widthf;
}
}
$thumbperf = imagecreatetruecolor($newwidthperf, $newheightperf);
imagecopyresampled($thumbperf, $imgperf, 0, 0, 0, 0, $newwidthperf, $newheightperf, $getsizesperf[0], $getsizesperf[1]);
if($newwidthperf == $widthf){
$x1 = 0;
$x2 = $widthf;
}else{
$sobraw = $newwidthperf - $widthf;
$mitadw = floor($sobraw / 2);
$x1 = $mitadw;
$x2 = $mitadw + $widthf;
}
if($newheightperf == $heightf){
$y1 = 0;
$y2 = $heightf;
}else{
$sobrah = $newheightperf - $heightf;
$mitadh = floor($sobrah / 2);
$y1 = $mitadh;
$y2 = $mitadh + $heighf;
}
$fpperf = imagecreatetruecolor ($widthf, $heightf);
imagecopy($fpperf, $thumbperf, 0, 0, $x1, $y1, $widthf, $heightf);
imagejpeg($fpperf,"",100);
imagedestroy($fpperf);
}
?>
He estado intentando editar este script desde las 9 AM y ya son las 2:57 am, todo el dia y no he podido conseguir que funcione "para no redimencionar las imagenes gif". Ayudenme un poquito por favor
Muchas gracias. Buenas noches