예제 #1
0
/**
 * 生成缩略图
 * @param string $imageFile
 */
function makeThumb($imageFile)
{
    if (!file_exists($imageFile)) {
        return false;
    }
    if (!yd_is_image($imageFile)) {
        return false;
    }
    $data = YdCache::readThumb();
    if ($data['THUMB_ENABLE'] == 1) {
        $w = $data['THUMB_WIDTH'];
        //缩略图宽度
        $h = $data['THUMB_HEIGHT'];
        //缩略图高度
        $type = $data['THUMB_TYPE'];
        //缩略图类型
        $filename = './Upload/thumb' . basename($imageFile);
        import('ORG.Util.Image.ThinkImage');
        $img = new ThinkImage(THINKIMAGE_GD, $imageFile);
        $img->thumb($w, $h, $type)->save($filename);
        if ($data['THUMB_WATER_ENABLE'] == 1) {
            //是否添加水印
            addWater($filename);
        }
        return $filename;
    } else {
        return $imageFile;
    }
}