$tam[1] && $tam[0]<$_GET["tam"]){ $tam_max=$tam[0]; } if ($tam[1]>$tam[0] && $tam[1]<$_GET["tam"]){ $tam_max=$tam[1]; } if ($tam[1]==$tam[0] && $tam[1]<$_GET["tam"]){ $tam_max=$tam[1]; } $ancho_ant=$tam[0]; $alto_ant=$tam[1]; if($tam[0]>$tam[1]){ //si es mas ancha que alta $quocient=$tam_max/$tam[0]; $tam[0]=$tam_max; $tam[1]=($tam[1]*$quocient); } if($tam[1]>$tam[0]){ $quocient=$tam_max/$tam[1]; $tam[1]=$tam_max; $tam[0]=($tam[0]*$quocient); } if ($tam[1]==$tam[0]){ $tam[0]=$tam_max; $tam[1]=$tam_max; } function gdVersion($user_ver = 0){ if (! extension_loaded('gd')) { return; } static $gd_ver = 0; // Just accept the specified setting if it's 1. if ($user_ver == 1) { $gd_ver = 1; return 1; } // Use the static variable if function was called previously. if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; } // Use the gd_info() function if possible. if (function_exists('gd_info')) { $ver_info = gd_info(); preg_match('/\d/', $ver_info['GD Version'], $match); $gd_ver = $match[0]; return $match[0]; } // If phpinfo() is disabled use a specified / fail-safe choice... if (preg_match('/phpinfo/', ini_get('disable_functions'))) { if ($user_ver == 2) { $gd_ver = 2; return 2; } else { $gd_ver = 1; return 1; } } // ...otherwise use phpinfo(). ob_start(); phpinfo(8); $info = ob_get_contents(); ob_end_clean(); $info = stristr($info, 'gd version'); preg_match('/\d/', $info, $match); $gd_ver = $match[0]; return $match[0]; } if (gdVersion()==2){ $img_src=imagecreatefromjpeg($imagem); $img_dst=imagecreatetruecolor($tam[0], $tam[1]); imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $tam[0], $tam[1], $ancho_ant, $alto_ant); imagejpeg($img_dst, $g_dstfile, 90); imagedestroy($img_dst); } if (gdVersion()==1){ $img_origem = imagecreatefromjpeg($imagem); $img_destino = imagecreate($tam[0],$tam[1]); imagecopyresized($img_destino, $img_origem,0,0,0,0,$tam[0],$tam[1],imagesx ($img_origem),imagesy($img_origem)); imageJPEG($img_destino,'',90); } ?>