我有这个代码可以生成一个缩略图,nw,我需要它来生成我两个...只是为了加倍功能,你能告诉我如何根据这个来做吗?
谢谢..
function tamano_nuevo_foto($im_or, $ancho_nv, $dir_nv) {
$img = imagecreatefromjpeg($im_or);
$datos = getimagesize($im_or);
$ancho = $datos[0];
$alto = $datos[1];
if ($ancho > $ancho_nv) { //Si la imagen no lelga al máximo no la tocamos.
$prop = $alto / $ancho;
$alto_nv = round($ancho_nv * $prop);
} else {
$ancho_nv = $ancho;
$alto_nv = $alto;
}
$im_nv = imagecreatetruecolor($ancho_nv, $alto_nv);
imagecopyresampled($im_nv, $img, 0, 0, 0, 0, $ancho_nv, $alto_nv, $ancho, $alto);
imagejpeg($im_nv, $dir_nv);
imagedestroy($im_nv);
}
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetPath = str_replace('//', '/', $targetPath);
$targetFile = $targetPath . basename($_FILES['Filedata']['name'], '.' . $ext) . '_s.';
tamano_nuevo_foto($tempFile, 120, $targetFile);
echo str_replace($_SERVER['DOCUMENT_ROOT'], '', $targetFile);
}