Cita:
Iniciado por gogupe
Gracias por contestar Darkj, pero lo tengo configurado a 16 Mb.
proba con esta funcion:
Código PHP:
function create_tb($img_o,$w_tb,$h_tb,$bg_color){
$img_return=imagecreatetruecolor($w_tb,$h_tb);
if(isset($bg_color) && $bg_color != ""){
$color= imagecolorallocate($img_return, hexdec(substr($bg_color,0,2)), hexdec(substr($bg_color,2,2)), hexdec(substr($bg_color,4,2)));
}else{
$color= imagecolorallocate($img_return, 255, 255, 255);
}
imagefilledrectangle($img_return, 0, 0, $w_tb, $h_tb, $color);
$wo=imagesx($img_o);
$ho=imagesy($img_o);
if($wo >= $ho){
$wtb_copy=$w_tb;
$htb_copy=($ho*(($w_tb*100)/$wo))/100;
$xtb_copy=0;
$ytb_copy=($h_tb/2)-($htb_copy/2);
}elseif($ho > $wo){
$wtb_copy=($wo*(($h_tb*100)/$ho))/100;
$htb_copy=$h_tb;
$xtb_copy=($w_tb/2)-($wtb_copy/2);
$ytb_copy=0;
}
imagecopyresampled($img_return, $img_o, $xtb_copy, $ytb_copy, 0, 0, $wtb_copy, $htb_copy, $wo, $ho);
return $img_return;
}
llamando a la funcion y validando.... --> aca le das los parametros:
Código PHP:
//// inicio de validacion ///
$valido = true;
$file=$_FILES["file"];
if($file["type"]=="image/pjpeg" || $file["type"]=="image/jpg" || $file["type"]=="image/jpeg"){
if($file["size"]>=5120000){
$valido = false;
echo "tamaño incorrecto";
}
}else{
$valido = false;
echo "tipo incorrecto";
}
//// fin de validacion ///
//// inicio llamando a la funcion ///
if($valido){
$imgagencapt=imagecreatefromjpeg($file["tmp_name"]);
$imggrande=create_tb($imgagencapt,150,150,"CCE6FF");
$imgChica=create_tb($imgagencapt,60,60,"CCE6FF");
imagejpeg($imggrande,"carpeta/imagen_".($ID).".jpg",60);
imagejpeg($imgChica,"carpeta/imagen_".($ID).".jpg",60);
}
}
//// fin de llamando a la funcion ///
incluso te deja crear 2 imagenes de la misma foto.. una chica 60x60 px y otra grande de 150 x150 px y rellena los espacios vacios con el color de fondo de tu pagina por ejemplo ahora ta rellenando con: CCE6FF
PD: tenes que tener habilitada la libreria GD