public static function thumb($obj = null, $options = array()) { if ($obj) { $thumb = new thumb($obj, $options); return $thumb->url(); } else { return "http://placehold.it/" . $options['width'] . "x" . $options['height'] . "&text= "; } }
<?php include_once './include/thumb.php'; $mythumb = new thumb(); $mythumb->loadImage('uploads/book82.jpg'); //$mythumb->resize(100, 'width'); $mythumb->crop(200, 150, "top"); $mythumb->save("test.jpg"); $mythumb->show();
function save_before() { parent::save_before(); front::$post['content'] = htmlspecialchars_decode(front::$post['content']); if(front::$post['htmlrule1'] != ''){ front::$post['htmlrule'] = front::$post['htmlrule1']; } front::$post['strong'] = intval(front::$post['strong']); $pics = array(); foreach(front::$post as $k =>$v) { if(preg_match('/pics(\d+)/i',$k,$out)) { if($v != ''){ $pics[$out[1]] = $v; } unset(front::$post[$k]); } } front::$post['pics'] = serialize($pics); if(!front::post('attr1')) { front::$post['attr1']=''; } if(!front::$post['introduce']){ front::$post['introduce']=cut(strip_tags(front::$post['content']),front::$post['introduce_len']*2); } if(front::$post['savehttppic']){ front::$post['content'] = stripslashes(front::$post['content']); front::$post['content'] = preg_replace_callback('%(<img\s[^>|/>]*?src\s*=\s*["|\']?)([^"|\'|\s>]*)%is','savepic', front::$post['content']); front::$post['content'] = addslashes(front::$post['content']); } //var_dump(front::$post['content']);exit; if(front::$post['autothumb']){ front::$post['content'] = stripslashes(front::$post['content']); preg_match('%(<img\s[^>|/>]*?src\s*=\s*["|\']?)([^"|\'|\s>]*)%is', front::$post['content'],$out); $out[1] = ''; //$out[2] = savepic1($out); if(!$out[2]) return; //front::$post['thumb'] = str_ireplace(config::get('site_url'),'',$out[2]); $len = 1; if(config::get('base_url') != '/'){ $len = strlen(config::get('base_url'))+1; } if(substr($out[2],0,4) == 'http'){ front::$post['thumb'] = str_ireplace(config::get('site_url'),'',$out[2]); }else{ front::$post['thumb'] = substr($out[2],$len); } $catid = front::get('catid'); $thumb=new thumb(); $thumb->set(front::$post['thumb'],'file'); front::$post['thumb'] = str_ireplace('.jpg','_s.jpg',front::$post['thumb']); if ($catid) $thumb->create(front::$post['thumb'],category::getwidthofthumb($catid),category::getheightofthumb($catid)); else $thumb->create(front::$post['thumb'],config::get('thumb_width'),config::get('thumb_height')); $sp = $len>1?'/':''; front::$post['thumb'] = config::get('base_url').$sp.front::$post['thumb']; if(substr(front::$post['thumb'], 0,1) != '/'){ front::$post['thumb'] = '/'.front::$post['thumb']; } front::$post['content'] = addslashes(front::$post['content']); } }
protected static function imageInfo($image) { $info = getimagesize($image); if ($info) { //图像的宽 self::$image_w = $info[0]; //图像的高 self::$image_h = $info[1]; //图像的后缀 self::$image_ext = ltrim(image_type_to_extension($info[2]), '.'); } }
function thumb($obj, $options = array(), $tag = true) { $thumb = new thumb($obj, $options); return $tag ? $thumb->tag() : $thumb->url(); }
<?php /** * @package EDK */ if (isset($_GET['int'])) { $thumb = new thumbInt($_GET['id'], intval($_GET['size']), slashfix($_GET['type'])); } else { $thumb = new thumb($_GET['id'], intval($_GET['size']), slashfix($_GET['type'])); } $thumb->display();
if (file_exists(CacheHandler::exists("{$plt_ext_id}_sig_{$id}.jpg", 'img'))) { // cache files for 120 minutes if (time() - CacheHandler::age("{$plt_ext_id}_sig_{$id}.jpg", 'img') < 120 * 60 || lastKill($plt_id) > 120 * 60) { if (isset($_SERVER['HTTP_IF_NONE_MATCH']) || isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { header($_SERVER["SERVER_PROTOCOL"] . " 304 Not Modified"); die; } else { header('Content-Type: image/jpeg'); readfile(CacheHandler::get("{$plt_ext_id}_sig_{$id}.jpg", 'img')); die; } } } $pid = $pilot->getExternalID(); $cachePath = $pilot->getPortraitPath(256); $thumb = new thumb($pid, 256); if (!$thumb->isCached()) { $thumb->genCache(); } // check template if (!is_dir(dirname(__FILE__) . '/signatures/' . $sig_name)) { errorPic('Template not found.'); } // let the template do the work, we just output $im require dirname(__FILE__) . '/signatures/' . $sig_name . '/' . $sig_name . '.php'; if (headers_sent()) { trigger_error('An error occured. Headers have already been sent.<br/>', E_USER_ERROR); } if (ob_get_contents()) { trigger_error('An error occured. Content has already been sent.<br/>', E_USER_ERROR); } else {
function getThumb($image, $thumbId = 0, $isCheck = false) { $upConf = C('upload', 'thumb_size'); if (!isset($upConf[$thumbId])) { $thumbId = 0; } if (strpos($image, 'yun/') === 0) { return $image . $upConf[$thumbId]['t']; } else { T('image/thumb'); return thumb::init($image, $upConf[$thumbId]['w'], $upConf[$thumbId]['h'], $isCheck); } }
function pruebaresize($url, $filename, $w, $h, $sel_width, $sel_height, $sel_x, $sel_y) { $len = strlen($filename); $pos = strripos($filename, "."); $ext = strtolower(substr($filename, ($len - $pos - 1) * -1)); $base = substr($filename, 0, $pos); $newImage = $base . "-" . $w . "x" . $h . "." . $ext; $mythumb = new thumb(); $mythumb->loadImage($url . $filename); $mythumb->crop($sel_width, $sel_height, $sel_x, $sel_y); $mythumb->save($url . $newImage); $mythumb = new thumb(); $mythumb->loadImage($url . $newImage); $mythumb->resize($h, 'height'); $mythumb->save($url . $newImage); }
public function save() { $dgClass = new dg(); if (!empty($_POST)) { $art = $_POST['art']; if (isset($_FILES["file"]["name"]) && $_FILES["file"]["name"] != '') { // create folder $root = dirname(ROOT) . DS . 'uploaded' . DS . 'cliparts' . DS . $art['cate_id']; if (!file_exists($root)) { mkdir($root, 0755, TRUE); } $upload_path = $root . DS . 'print' . DS; if (!is_dir($upload_path)) { mkdir($upload_path, 0755, TRUE); } // upload file require_once dirname(ROOT) . DS . 'includes' . DS . 'upload.php'; $uploader = new Uploader(); $uploader->setDir($upload_path); $uploader->setExtensions(array('jpg', 'jpeg', 'png', 'gif', 'svg')); $uploader->setMaxSize(10); $uploader->sameName(false); if ($uploader->uploadFile('file')) { $image = $uploader->getUploadName(); $extension = $uploader->getExtension($image); $extension = strtolower($extension); $url = site_url('uploaded/cliparts/'); $url = str_replace('/admin/', '/', $url); $art['file_type'] = $extension; $art['file_name'] = $image; $art['path'] = $url; $art['url'] = $url . $art['cate_id'] . '/'; // create folder thumb $thumbs = $root . DS . 'thumbs'; if (!is_dir($thumbs)) { mkdir($thumbs, 0755, TRUE); } $medium = $root . DS . 'medium'; if (!is_dir($medium)) { mkdir($medium, 0755, TRUE); } if ($extension == 'svg') { $art['change_color'] = 1; $art['thumb'] = 'print/' . $image; $art['medium'] = 'print/' . $image; } else { require_once ROOT . DS . 'includes' . DS . 'thumb.php'; $thumb = new thumb($upload_path . $image); $thumb->resize(null, 100, 100, $thumbs . DS . md5($image) . '.' . $extension); $thumb->resize(null, 300, 300, $medium . DS . md5($image . 'medium') . '.' . $extension); $art['thumb'] = 'thumbs/' . md5($image) . '.' . $extension; $art['medium'] = '/medium/' . md5($image . 'medium') . '.' . $extension; $art['change_color'] = 0; } } else { echo $uploader->getMessage(); } } $art['price'] = (double) $art['price']; $file = dirname(ROOT) . DS . 'data' . DS . 'arts.json'; // check file if (!file_exists($file)) { $dgClass->redirect('index.php/clipart'); return; } $data = file_get_contents($file); $arts = json_decode($data); $is_new = true; $conent = array(); if (isset($_POST['id']) && $_POST['id'] > 0) { $id = $_POST['id']; // update clipart if (isset($arts->arts) && count($arts->arts) > 0) { foreach ($arts->arts as $row) { if ($row->clipart_id == $id) { $art['clipart_id'] = $id; $conent[] = $art; $is_new = false; } else { $conent[] = $row; } } } } if ($is_new === true) { $index = 0; foreach ($arts->arts as $row) { if ($row->clipart_id > $index) { $index = $row->clipart_id; } $conent[] = $row; } $art['clipart_id'] = $index + 1; $conent[] = $art; $arts->count = $arts->count + 1; } $arts->arts = $conent; $dgClass->WriteFile($file, json_encode($arts)); $dgClass->redirect('index.php/clipart'); } else { $dgClass->redirect('index.php/clipart'); } }
function create_image($source, $route, $new_w) { require_once 'thumbnails.php'; $image = new thumb(); $image->loadImage($source); $image->resize($new_w, 'width'); $image->save($route, 100); }
function goPCA($type, $id, $size = 64, $imghost = "") { //TODO integrate the existing common/includes/class.thumb.php if ($size != 32 && $size != 64 && $size != 128 && $size != 256) { show404(); } $year = 31536000; // 365 * 24 * 60 * 60 // PHP5.3+ only //header_remove(); // Instead: header("Cache-Control: public"); header("Expires: " . gmdate("D, d M Y H:i:s", time() + $year) . " GMT"); header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . " GMT"); global $mc, $config; include_once 'kbconfig.php'; require_once 'common/includes/globals.php'; $config = new Config(); if (isset($_GET['int'])) { header("Location: {$imghost}?a=thumb&id={$id}&int=1&size={$size}&type={$type}"); die; } else { $thumb = new thumb($id, $size, $type); } $thumb->display(); die; }
function thumb($obj, $options = array()) { $thumb = new thumb($obj, $options); return $thumb->tag(); }
<?php header('Content-Type: image/jpg'); include_once 'thumb.php'; $nombreImg = isset($_GET["img"]) ? $_GET["img"] : "avatarimg"; $resolution = isset($_GET["size"]) ? $_GET["size"] : "100-w"; if ($resolution == '') { $resolution = "100-w"; } if ($nombreImg == '') { $nombreImg = "avatarimg.jpg"; } $widthheight = array("w" => "width", "h" => "height"); list($pixeles, $orientacion) = explode("-", $resolution); $mythumb = new thumb(); $mythumb->loadImage("../../img/" . $nombreImg); $mythumb->resize($pixeles, $widthheight[$orientacion]); $mythumb->show();
function cut_image_action() { $len = 1; if(config::get('base_url') != '/'){ $len = strlen(config::get('base_url'))+1; } if(substr($_POST['pic'],0,4) == 'http'){ front::$post['thumb'] = str_ireplace(config::get('site_url'),'',$_POST['pic']); }else{ front::$post['thumb'] = substr($_POST['pic'],$len); } $thumb=new thumb(); $thumb->set(front::$post['thumb'],'jpg'); $img=$thumb->create_image($thumb->im,$_POST['w'],$_POST['h'],0,0,$_POST['x1'],$_POST['y1'],$_POST['x2'] -$_POST['x1'],$_POST['y2'] -$_POST['y1']); $new_name=$new_name_gbk=str_replace('.','',Time::getMicrotime()).'.'.end(explode('.',$_POST['pic'])); $save_file='upload/images/'.date('Ym').'/'.$new_name; @mkdir(dirname(ROOT.'/'.$save_file)); ob_start(); $thumb->out_image($img,null,85); file_put_contents(ROOT.'/'.$save_file,ob_get_contents()); ob_end_clean(); $image_url=config::get('base_url').'/'.$save_file; //$res['size']=ceil(strlen($img) / 1024); $res['code']=" //$('#cut_preview').attr('src','$image_url'); $('#thumb').val('$image_url'); alert('保存成功'); "; echo json::encode($res); }