/ Published in: PHP
Expand |
Embed | Plain Text
function crear_miniatura($name,$filename,$new_w,$new_h,$carpeta){ $old_x=imageSX($src_img); $old_y=imageSY($src_img); $proporcion = $old_x/$old_y; $proporcion_correcta = $new_w/$new_h; if ($proporcion >= $proporcion_correcta) { $recorte_h=$old_y; $recorte_w=$old_y*$proporcion_correcta; }else{ // si es vertical $recorte_h=$old_y; $recorte_w=$old_y*$proporcion_correcta; //$recorte_w=$old_x; //$recorte_h=$old_x/$proporcion_correcta; } $x_recorte = $old_x/2 - $recorte_w/2; $y_recorte = $old_y/2 - $recorte_h/2; $dst_img=ImageCreateTrueColor($new_w,$new_h); imagecopyresampled($dst_img,$src_img,0,0,$x_recorte,$y_recorte,$new_w,$new_h,$recorte_w,$recorte_h); imagejpeg($dst_img,$carpeta.$filename,85); imagedestroy($dst_img); imagedestroy($src_img); } crear_miniatura($_FILES['Filedata']['tmp_name'],$nuevo_nom,400,300,"../media/"); crear_miniatura($_FILES['Filedata']['tmp_name'],"pq_".$nuevo_nom,40,40,"../media/");
You need to login to post a comment.
