Esempio n. 1
0
    if (!$quality) {
        $quality = bu::config('rc/quality');
    }
    $width = $maxWidth;
    $height = $maxHeight;
    list($width_orig, $height_orig) = getimagesize($origName);
    $ratio_orig = $width_orig / $height_orig;
    if ($width_orig < $width and $height_orig < $height) {
        $width = $width_orig;
        $height = $height_orig;
    } elseif ($width / $height > $ratio_orig) {
        $width = $height * $ratio_orig;
    } else {
        $height = $width / $ratio_orig;
    }
    bu::lib('opt/smart_resize_image/smart_resize_image.function');
    smart_resize_image($origName, $width, $height, false, $destName, false);
}
$name = getUniqueName($fileType);
$finalDir = bu::config('rc/uploadPath') . '/' . getDirForString($name);
$finalSmallDir = bu::config('rc/smallImgPath') . '/' . getDirForString($name);
if (!file_exists($finalDir)) {
    mkdir($finalDir, 0775, true);
    mkdir($finalSmallDir, 0775, true);
}
$finalPath = bu::config('rc/uploadPath') . '/' . makePathForString($name, $fileType);
$finalSmallPath = bu::config('rc/smallImgPath') . '/' . makePathForString($name, $fileType);
move_uploaded_file($tmpName, $finalPath);
resizeImage($finalPath, $finalSmallPath);
bu::redirect('/links.php?img=' . getUrlForString($name, $fileType));
#$path = makePathForString($name, $fileType);