Esempio n. 1
0
function MakeThumbnail($upfiledir, $src, $tName, $tw = '', $th = '', $scale = true, $tDir = "thumb")
{
    global $iCMS;
    $R = array();
    $image = "";
    $tMap = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
    $tw = empty($tw) ? (int) $iCMS->config['thumbwidth'] : $tw;
    $th = empty($th) ? (int) $iCMS->config['thumbhight'] : $th;
    if ($tw && $th) {
        list($width, $height, $type) = @getimagesize($src);
        if ($width < 1 && $height < 1) {
            $R['width'] = $tw;
            $R['height'] = $th;
            $R['src'] = $src;
            return $R;
        }
        if ($width > $tw || $height > $th) {
            createdir($upfiledir . $tDir);
            if ($scale) {
                $im = scale_image(array("mw" => $tw, "mh" => $th, "cw" => $width, "ch" => $height));
            } else {
                $im = array('w' => $tw, 'h' => $th);
            }
            $R['width'] = $im['w'];
            $R['height'] = $im['h'];
            $tName .= '_' . $R['width'] . 'x' . $R['height'];
            $img = icf($tMap[$type], $src);
            if ($img['res']) {
                $thumb = imagecreatetruecolor($im['w'], $im['h']);
                imagecopyresampled($thumb, $img['res'], 0, 0, 0, 0, $im['w'], $im['h'], $width, $height);
                PHP_VERSION != '4.3.2' && UnsharpMask($thumb);
                $R['src'] = $upfiledir . $tDir . "/" . $tName;
                __image($thumb, $img['type'], $R['src']);
                $R['src'] .= '.' . $img['type'];
            } else {
                $R['src'] = $src;
            }
        } else {
            $R['width'] = $width;
            $R['height'] = $height;
            $R['src'] = $src;
        }
        return $R;
    }
}
Esempio n. 2
0
        }
        ?>
 
                            </b> </label>
                            <div class="controls">
                                <?php 
        $e = $v['element'];
        if (!empty($e) && isset($e[0])) {
            switch (strtolower(trim($e[0]))) {
                case 'image':
                    $attributes = array();
                    if (isset($e[1]) && !empty($e[1])) {
                        $attributes = $e[1];
                    }
                    $attributes['style'] = 'display:none;';
                    echo __image('data.' . $field, $attributes);
                    break;
                case 'text':
                    $attributes = array();
                    if (isset($e[1]) && !empty($e[1])) {
                        $attributes = $e[1];
                    }
                    echo __text('data.' . $field, $attributes);
                    break;
                case 'date':
                    $attributes = array();
                    $attributes['style'] = "width:180px;";
                    if (isset($e[1]) && !empty($e[1])) {
                        $attributes = $e[1];
                    }
                    echo __date('data.' . $field, $attributes);
Esempio n. 3
0
        if ($width == $_width && $height == $_height) {
            //不对源图缩放
            $_img = icf($tMap[$type], $iPic);
            $_Type = $_img['type'];
        } else {
            $img = icf($tMap[$type], $iPic);
            $_Type = $img['type'];
            if ($img['res']) {
                $thumb = imagecreatetruecolor($_width, $_height);
                imagecopyresampled($thumb, $img['res'], 0, 0, 0, 0, $_width, $_height, $width, $height);
                $_tmpfile = $iCMS->config['uploadfiledir'] . '/crop_tmp_' . time() . rand(1, 999999);
                __image($thumb, $_Type, getfilepath($_tmpfile, iPATH, '+'));
                $_tmpfile .= '.' . $_Type;
                $_img = icf($tMap[$type], $_tmpfile);
                delfile($_tmpfile);
            }
        }
        if ($_img['res']) {
            $_thumb = imagecreatetruecolor($w, $h);
            imagecopyresampled($_thumb, $_img['res'], 0, 0, $x, $y, $w, $h, $w, $h);
            $thumbpath = substr($iPic, 0, strrpos($iPic, '/')) . "/thumb";
            $picName = substr($iPic, 0, strrpos($iPic, '.'));
            $picName = substr($picName, strrpos($picName, '/'));
            $fileName = $thumbpath . $picName . '_' . $w . 'x' . $h;
            createdir($thumbpath);
            __image($_thumb, $_img['type'], $fileName);
            $fileName .= '.' . $_Type;
            alert($pic . ' 剪裁成功!', 'javascript:insert("' . $iCMS->dir . getfilepath($fileName, iPATH, '-') . '","' . $_POST['in'] . '");');
        }
        break;
}