$anchura || $datos[1] > $hmax){ //ajustamos altura y anchura If ($anchura <> "" && $hmax <> ""){ If ($datos[0] > $datos[1]){ $anchura = $anchura; $altura = $datos[1] * $anchura / $datos[0]; if($datos[1]>$hmax){ $altura = $hmax; $anchura = $datos[0] * $altura / $datos[1]; } }Else{ $altura = $hmax; $anchura = $datos[0] * $altura / $datos[1]; if($datos[0] >$anchura){ $anchura = $anchura; $altura = $datos[1] * $anchura / $datos[0]; } } }ElseIf ($hmax <> ""){ $altura = $hmax; $anchura = $datos[0] * $altura / $datos[1]; }ElseIf ($anchura <> ""){ $anchura = $anchura; $altura = $datos[1] * $anchura / $datos[0]; } // echo $altura."---".$anchura; // $ratio = ($datos[0] / $anchura); // $altura = ($datos[1] / $ratio); // if($altura>$hmax){$anchura2=$hmax*$anchura/$altura;$altura=$hmax;$anchura=$anchura2;} //$thumb = imagecreatetruecolor($anchura,$altura); $thumb = imagecreatetruecolor($anchura,$altura); imagecopyresampled($thumb, $img, 0, 0, 0, 0, $anchura, $altura, $datos[0], $datos[1]); if ($crop!=""){ if ($altura > $crop){ $thumbCrop = imagecreatetruecolor($anchura,$crop); $xorigen = ($altura-$crop)/2; $yorigen = 0; imagecopyresampled($thumbCrop, $thumb, 0, 0, 0, $xorigen, $anchura, $crop+$xorigen, $anchura, $crop +$xorigen); $thumb = $thumbCrop; } } // mostramos la imagen if($datos[2]==1){header("Content-type: image/gif"); imagegif($thumb);} if($datos[2]==2){header("Content-type: image/jpeg");imagejpeg($thumb);} if($datos[2]==3){header("Content-type: image/png");imagepng($thumb); } //Limpiamos temporal imagedestroy($thumb); /* }else{ if($datos[2]==1){header("Content-type: image/gif"); imagegif($img);} if($datos[2]==2){header("Content-type: image/jpeg");imagejpeg($img);} if($datos[2]==3){header("Content-type: image/png");imagepng($img); } }*/ }else{ if($datos[2]==1){header("Content-type: image/gif"); imagegif($imagen);} if($datos[2]==2){header("Content-type: image/jpeg");imagejpeg($imagen);} if($datos[2]==3){header("Content-type: image/png");imagepng($imagen); } } }else{ $ext_file = explode(".",strtolower($nombre)); if ($ext_file[1]="swf"){ $ext_file[1] = "x-shockwave-flash"; } $imagen=str_replace("//","/",$imagen); echo $ext_file[1]; header("Content-type: application/".$ext_file[1]); header('Content-Disposition: attachment; filename="'.basename($imagen).'"'); readfile($imagen); } ?>