Código PHP:
<?php
function resize($origen){
$origen="galerias/holas/holas-03.jpg";
$ancho =80;
$imgancho =imagesx($origen);
if($imgancho<=$ancho){
return $origen;
}
$imgalto=imagesy($origen);
$alto=$ancho*($imgalto/$imgancho);
$imagen=imagecreate($ancho,$alto);
imagecopyresized($imagen,$origen,0,0,0,0,$ancho,$alto,$imgancho,$imgalto);
$ext=split("[.]",$origen);
$ext=$ext[1];
echo "$ext";
if($ext=='jpg' || $ext=='jpeg'){
$imagen = resize(imagecreatefromjpeg($file));
header("Content-type: image/jpeg");
header("Content-Disposition: inline; filename=".basename($file));
imagejpeg($imagen);
}else if($ext=='png'){
$imagen = resize(imagecreatefrompng($file));
header("Content-type: image/png");
header("Content-Disposition: inline; filename=".basename($file));
imagepng($imagen);
}else if($ext=='gif'){
$imagen = resize(imagecreatefromgif($file));
header("Content-type: image/gif");
header("Content-Disposition: inline; filename=".basename($file));
imagegif($imagen);
}
return $imagen;
}
?>