当前位置: 首页>>代码示例>>PHP>>正文


PHP Image::watermark方法代码示例

本文整理汇总了PHP中Image::watermark方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::watermark方法的具体用法?PHP Image::watermark怎么用?PHP Image::watermark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image::watermark方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: image

 /**
  * Image caching
  *
  * Resize & cache image into the file system. Returns the template image if product image is not exists
  * At this time supports JPG images only
  *
  * @param mixed $name
  * @param int $user_id
  * @param int $width Resizing width
  * @param int $height Resizing height
  * @param bool $watermarked
  * @param bool $overwrite
  * @return string Cached Image URL
  */
 public function image($name, $user_id, $width, $height, $watermarked = false, $overwrite = false)
 {
     $storage = DIR_STORAGE . $user_id . DIR_SEPARATOR . $name . '.' . ALLOWED_IMAGE_EXTENSION;
     $cache = DIR_IMAGE . 'cache' . DIR_SEPARATOR . $user_id . DIR_SEPARATOR . $name . '-' . $width . '-' . $height . '.' . ALLOWED_IMAGE_EXTENSION;
     $watermark = DIR_IMAGE . 'common' . DIR_SEPARATOR . 'watermark.png';
     $cached_url = ($this->_request->getHttps() ? HTTPS_IMAGE_SERVER : HTTP_IMAGE_SERVER) . 'cache' . DIR_SEPARATOR . $user_id . DIR_SEPARATOR . $name . '-' . $width . '-' . $height . '.' . ALLOWED_IMAGE_EXTENSION;
     // Force reset
     if ($overwrite) {
         unlink($cache);
     }
     // If image is cached
     if (file_exists($cache)) {
         return $cached_url;
         // If image not cached
     } else {
         // Create directories by path if not exists
         $directories = explode(DIR_SEPARATOR, $cache);
         $path = '';
         foreach ($directories as $directory) {
             $path .= DIR_SEPARATOR . $directory;
             if (!is_dir($path) && false === strpos($directory, '.')) {
                 mkdir($path, 0755);
             }
         }
         // Prepare new image
         $image = new Image($storage);
         $image->resize($width, $height);
         if ($watermarked) {
             $image->watermark($watermark);
         }
         $image->save($cache);
     }
     return $cached_url;
 }
开发者ID:RustyNomad,项目名称:bitsybay,代码行数:48,代码来源:cache.php

示例2: upload

function upload()
{
    $path = "./uploads/";
    //设置图片上传路径
    $up = new FileUpload($path);
    //创建文件上传类对象
    if ($up->upload('pic')) {
        //上传图片
        $filename = $up->getFileName();
        //获取上传后的图片名
        $img = new Image($path);
        //创建图像处理类对象
        $img->thumb($filename, 300, 300, "");
        //将上传的图片都缩放至在300X300以内
        $img->thumb($filename, 80, 80, "icon_");
        //缩放一个80x80的图标,使用icon_作前缀
        $img->watermark($filename, "logo.gif", 5, "");
        //为上传的图片加上图片水印
        return array(true, $filename);
        //如果成功返回成功状态和图片名称
    } else {
        return array(false, $up->getErrorMsg());
        //如果失败返回失败状态和错误消息
    }
}
开发者ID:EmbededC,项目名称:Community-resource-management,代码行数:25,代码来源:func.inc.php

示例3: image

 /**
  * Image caching
  *
  * Resize & cache image into the file system. Returns the template image if product image is not exists
  *
  * @param mixed $name
  * @param int $user_id
  * @param int $width Resizing width
  * @param int $height Resizing height
  * @param bool $watermarked
  * @param bool $overwrite
  * @param bool $best_fit
  * @return string Cached Image URL
  */
 public function image($name, $user_id, $width, $height, $watermarked = false, $overwrite = false, $best_fit = false)
 {
     $storage = DIR_STORAGE . $user_id . DIR_SEPARATOR . $name . '.' . STORAGE_IMAGE_EXTENSION;
     $cache = DIR_IMAGE . 'cache' . DIR_SEPARATOR . $user_id . DIR_SEPARATOR . $name . '-' . (int) $best_fit . '-' . $width . '-' . $height . '.' . STORAGE_IMAGE_EXTENSION;
     $watermark_black = DIR_IMAGE . 'common' . DIR_SEPARATOR . 'watermark-black.png';
     $watermark_white = DIR_IMAGE . 'common' . DIR_SEPARATOR . 'watermark-white.png';
     $cached_url = URL_BASE . 'image' . DIR_SEPARATOR . 'cache' . DIR_SEPARATOR . $user_id . DIR_SEPARATOR . $name . '-' . (int) $best_fit . '-' . $width . '-' . $height . '.' . STORAGE_IMAGE_EXTENSION;
     // Force reset
     if ($overwrite && file_exists($overwrite)) {
         unlink($cache);
     }
     // If image is cached
     if (file_exists($cache)) {
         return $cached_url;
         // If image not cached
     } else {
         // Create directories by path if not exists
         $directories = explode(DIR_SEPARATOR, $cache);
         $path = '';
         foreach ($directories as $directory) {
             $path .= DIR_SEPARATOR . $directory;
             if (!is_dir($path) && false === strpos($directory, '.')) {
                 mkdir($path, 0755);
             }
         }
         // Prepare new image
         $image = new Image($storage);
         $image->resize($width, $height, 1, false, $best_fit);
         if ($watermarked) {
             $average = new Imagick($storage);
             $average->resizeImage(1, 1, Imagick::FILTER_POINT, 0);
             $pixel = $average->getImagePixelColor(1, 1);
             $color = $pixel->getColor();
             $brightness = (0.299 * $color['r'] + 0.587 * $color['g'] + 0.114 * $color['b']) * 100 / 255;
             if ($brightness < 25) {
                 $image->watermark($watermark_white);
             } else {
                 $image->watermark($watermark_black);
             }
         }
         $image->save($cache);
     }
     return $cached_url;
 }
开发者ID:bitsybay,项目名称:bitsybay,代码行数:58,代码来源:cache.php

示例4: resize

 public function resize($filename, $width, $height)
 {
     if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
         return;
     }
     $info = pathinfo($filename);
     $extension = $info['extension'];
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
     if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname(str_replace('../', '', $new_image)));
         foreach ($directories as $directory) {
             $path = $path . '/' . $directory;
             if (!file_exists(DIR_IMAGE . $path)) {
                 @mkdir(DIR_IMAGE . $path, 0777);
             }
         }
         list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
         if ($width_orig != $width || $height_orig != $height) {
             $image = new Image(DIR_IMAGE . $old_image);
             $image->resize($width, $height);
             // tokoonline
             $watermark_path = str_replace("\\", '/', DIR_IMAGE) . 'watermark.png';
             if ($width > 100 || $height > 100 and strpos($old_image, 'banner') === false and file_exists($watermark_path)) {
                 $image->watermark($watermark_path, 'center');
             }
             $image->save(DIR_IMAGE . $new_image);
         } else {
             copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
         }
     }
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         return HTTPS_IMAGE . $new_image;
     } else {
         return HTTP_IMAGE . $new_image;
     }
 }
开发者ID:ekachandrasetiawan,项目名称:SuprabaktiShop,代码行数:38,代码来源:image.php

示例5: resizenodimension

 public function resizenodimension($filename, $width, $height, $type = "")
 {
     if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
         return;
     }
     $info = pathinfo($filename);
     $extension = $info['extension'];
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . $type . '.' . $extension;
     if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname(str_replace('../', '', $new_image)));
         foreach ($directories as $directory) {
             $path = $path . '/' . $directory;
             if (!file_exists(DIR_IMAGE . $path)) {
                 @mkdir(DIR_IMAGE . $path, 0777);
             }
         }
         list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
         if ($width_orig != $width || $height_orig != $height) {
             $image = new Image(DIR_IMAGE . $old_image);
             // Bukatoko
             if ($width > 400 || $height > 400) {
                 $image->watermark(DIR_IMAGE . 'data/watermark/watermark.png', 'center');
             }
             $image->resize($width, $height, $type);
             $image->save(DIR_IMAGE . $new_image);
         } else {
             copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
         }
     }
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         return $this->config->get('config_ssl') . 'image/' . $new_image;
     } else {
         return $this->config->get('config_url') . 'image/' . $new_image;
     }
 }
开发者ID:bukastudio,项目名称:themes-2016,代码行数:37,代码来源:image.php

示例6: resize

 public function resize($filename, $width, $height)
 {
     if (!is_file(DIR_IMAGE . $filename)) {
         return;
     }
     $extension = pathinfo($filename, PATHINFO_EXTENSION);
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
     if (!is_file(DIR_IMAGE . $new_image) || filectime(DIR_IMAGE . $old_image) > filectime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname(str_replace('../', '', $new_image)));
         foreach ($directories as $directory) {
             $path = $path . '/' . $directory;
             if (!is_dir(DIR_IMAGE . $path)) {
                 @mkdir(DIR_IMAGE . $path, 0777);
             }
         }
         list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
         if ($width_orig != $width || $height_orig != $height) {
             $image = new Image(DIR_IMAGE . $old_image);
             //超过500就添加水印
             if ($width > 500 || $height > 500) {
                 $image->watermark(DIR_IMAGE . 'watermark.png', 'center');
             }
             $image->resize($width, $height);
             $image->save(DIR_IMAGE . $new_image);
         } else {
             copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
         }
     }
     if ($this->request->server['HTTPS']) {
         return $this->config->get('config_ssl') . 'image/' . $new_image;
     } else {
         return $this->config->get('config_url') . 'image/' . $new_image;
     }
 }
开发者ID:EnzoLynn,项目名称:gugu123,代码行数:36,代码来源:image.php

示例7: upload

 public function upload()
 {
     $this->load->language('common/filemanager');
     $json = array();
     if (isset($this->request->post['directory'])) {
         if (isset($this->request->files['image']) && $this->request->files['image']['tmp_name']) {
             $filename = basename(html_entity_decode($this->request->files['image']['name'], ENT_QUOTES, 'UTF-8'));
             if (strlen($filename) < 3 || strlen($filename) > 255) {
                 $json['error'] = $this->language->get('error_filename');
             }
             $directory = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']), '/');
             if (!is_dir($directory)) {
                 $json['error'] = $this->language->get('error_directory');
             }
             if ($this->request->files['image']['size'] > 500000) {
                 $json['error'] = $this->language->get('error_file_size');
             }
             $allowed = array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', 'application/x-shockwave-flash');
             if (!in_array($this->request->files['image']['type'], $allowed)) {
                 $json['error'] = $this->language->get('error_file_type');
             }
             $allowed = array('.jpg', '.jpeg', '.gif', '.png', '.flv');
             if (!in_array(strtolower(strrchr($filename, '.')), $allowed)) {
                 $json['error'] = $this->language->get('error_file_type');
             }
             if ($this->request->files['image']['error'] != UPLOAD_ERR_OK) {
                 $json['error'] = 'error_upload_' . $this->request->files['image']['error'];
             }
         } else {
             $json['error'] = $this->language->get('error_file');
         }
     } else {
         $json['error'] = $this->language->get('error_directory');
     }
     if (!$this->user->hasPermission('modify', 'common/filemanager')) {
         $json['error'] = $this->language->get('error_permission');
     }
     if (!isset($json['error'])) {
         if (@move_uploaded_file($this->request->files['image']['tmp_name'], $directory . '/' . $filename)) {
             /**
              * 判断是否需要加水印
              */
             $watermark = isset($this->request->post['watermark']) ? $this->request->post['watermark'] : '';
             if (!empty($watermark)) {
                 $this->load->model('tool/image');
                 $image = new Image($directory . '/' . $filename);
                 $image->watermark(DIR_IMAGE . 'watermark.png', $watermark);
                 $image->save($directory . '/' . $filename);
             }
             $json['success'] = $this->language->get('text_uploaded');
         } else {
             $json['error'] = $this->language->get('error_uploaded');
         }
     }
     $this->response->setOutput(json_encode($json));
 }
开发者ID:laiello,项目名称:hecart,代码行数:56,代码来源:filemanager.php

示例8: applyWatermark

 /**
  * Получает путь к картинке и накладывает водяные знаки
  *
  * @param	string
  * @return	string
  */
 private function applyWatermark($filename)
 {
     if (!empty($filename)) {
         $info = pathinfo($filename);
         $wmfile = DIR_IMAGE . $this->config->get('exchange1c_watermark');
         if (is_file($wmfile)) {
             $extension = $info['extension'];
             $minfo = getimagesize($wmfile);
             $image = new Image(DIR_IMAGE . $filename);
             $image->watermark($wmfile, 'center', $minfo['mime']);
             $new_image = utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '_watermark.' . $extension;
             $image->save(DIR_IMAGE . $new_image);
             return $new_image;
         } else {
             return $filename;
         }
     } else {
         return 'no_image.jpg';
     }
 }
开发者ID:posterfield,项目名称:opencart-exchange1c,代码行数:26,代码来源:exchange1c.php

示例9: watermark

/**
 * 水印添加
 *
 * @param $source 原图片路径
 * @param $target 生成水印图片途径,默认为空,覆盖原图
 */
function watermark($source, $target = '')
{
    static $image = null;
    if (empty($source)) {
        return $source;
    }
    if (!extension_loaded('gd') || strpos($source, '://')) {
        return $source;
    }
    if (!$target) {
        $target = $source;
    }
    if ($image == null) {
        $image = new Image(0);
    }
    $image->watermark($source, $target);
    return $target;
}
开发者ID:hubs,项目名称:yuncms,代码行数:24,代码来源:custom.php

示例10: upload

 /**
  * 附件上传方法
  *
  * @param $field 上传字段
  * @param $alowexts 允许上传类型
  * @param $maxsize 最大上传大小
  * @param $overwrite 是否覆盖原有文件
  * @param $thumb_setting 缩略图设置
  * @param $watermark_enable 是否添加水印
  */
 public function upload($field, $alowexts = '', $maxsize = 0, $overwrite = 0, $thumb_setting = array(), $watermark_enable = 1)
 {
     if (!isset($_FILES[$field])) {
         // 判断附件上传字段是否为空
         $this->error = UPLOAD_ERR_OK;
         return false;
     }
     if (empty($alowexts) || $alowexts == '') {
         // 判断限制的类型
         $alowexts = C('attachment', 'allowext');
     }
     $fn = isset($_GET['CKEditorFuncNum']) ? $_GET['CKEditorFuncNum'] : '1';
     $this->field = $field;
     $this->savepath = $this->upload_root . date('Y/md/');
     $this->alowexts = $alowexts;
     $this->maxsize = $maxsize;
     $this->overwrite = $overwrite;
     $uploadfiles = array();
     $description = isset($GLOBALS[$field . '_description']) ? $GLOBALS[$field . '_description'] : array();
     if (is_array($_FILES[$field]['error'])) {
         $this->uploads = count($_FILES[$field]['error']);
         foreach ($_FILES[$field]['error'] as $key => $error) {
             if ($error === UPLOAD_ERR_NO_FILE) {
                 continue;
             }
             if ($error !== UPLOAD_ERR_OK) {
                 $this->error = $error;
                 return false;
             }
             $uploadfiles[$key] = array('tmp_name' => $_FILES[$field]['tmp_name'][$key], 'name' => $_FILES[$field]['name'][$key], 'type' => $_FILES[$field]['type'][$key], 'size' => $_FILES[$field]['size'][$key], 'error' => $_FILES[$field]['error'][$key], 'description' => $description[$key], 'fn' => $fn);
         }
     } else {
         $this->uploads = 1;
         if (!$description) {
             $description = '';
         }
         $uploadfiles[0] = array('tmp_name' => $_FILES[$field]['tmp_name'], 'name' => $_FILES[$field]['name'], 'type' => $_FILES[$field]['type'], 'size' => $_FILES[$field]['size'], 'error' => $_FILES[$field]['error'], 'description' => $description, 'fn' => $fn);
     }
     if (!Folder::mk($this->savepath) && !is_dir($this->savepath)) {
         $this->error = '8';
         return false;
     }
     @chmod($this->savepath, 0755);
     if (!is_writeable($this->savepath)) {
         $this->error = '9';
         return false;
     }
     $aids = array();
     foreach ($uploadfiles as $k => $file) {
         $fileext = File::get_suffix($file['name']);
         if ($file['error'] != 0) {
             $this->error = $file['error'];
             return false;
         }
         if (!preg_match("/^(" . $this->alowexts . ")\$/", $fileext)) {
             $this->error = '10';
             return false;
         }
         if ($this->maxsize && $file['size'] > $this->maxsize) {
             $this->error = '11';
             return false;
         }
         if (!$this->isuploadedfile($file['tmp_name'])) {
             $this->error = '12';
             return false;
         }
         $temp_filename = $this->getname($fileext);
         $savefile = $this->savepath . $temp_filename;
         $savefile = preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\\.|\$)/i", "_\\1\\2", $savefile);
         $filepath = preg_replace(String::addslashes("|^" . $this->upload_root . "|"), "", $savefile);
         if (!$this->overwrite && file_exists($savefile)) {
             continue;
         }
         $upload_func = $this->upload_func;
         if (@$upload_func($file['tmp_name'], $savefile)) {
             $this->uploadeds++;
             @chmod($savefile, 0755);
             @unlink($file['tmp_name']);
             $file['name'] = iconv("utf-8", CHARSET, $file['name']);
             $uploadedfile = array('filename' => $file['name'], 'filepath' => $filepath, 'filesize' => $file['size'], 'fileext' => $fileext, 'fn' => $file['fn']);
             if ($this->is_image($file['name'])) {
                 $thumb_enable = is_array($thumb_setting) && ($thumb_setting[0] > 0 || $thumb_setting[1] > 0) ? 1 : 0;
                 $image = new Image($thumb_enable);
                 if ($thumb_enable) {
                     $image->thumb($savefile, '', $thumb_setting[0], $thumb_setting[1]);
                 }
                 if ($watermark_enable) {
                     $image->watermark($savefile, $savefile);
                 }
             }
//.........这里部分代码省略.........
开发者ID:hubs,项目名称:yuncms,代码行数:101,代码来源:Attachment.php

示例11: upload

 public function upload()
 {
     //if($_POST['swf_auth_key']!= sysmd5($_POST['PHPSESSID'].$this->userid)) $this->ajaxReturn(0,'1-'.$_POST['PHPSESSID'],0);
     import("@.ORG.UploadFile");
     $upload = new UploadFile();
     //$upload->supportMulti = false;
     //设置上传文件大小
     $upload->maxSize = $this->Config['attach_maxsize'];
     $upload->autoSub = true;
     $upload->subType = 'date';
     $upload->dateFormat = 'Ym';
     //设置上传文件类型
     $upload->allowExts = explode(',', $this->Config['attach_allowext']);
     //设置附件上传目录
     $upload->savePath = UPLOAD_PATH;
     //设置上传文件规则
     $upload->saveRule = uniqid;
     //删除原图
     $upload->thumbRemoveOrigin = true;
     if (!$upload->upload()) {
         $this->ajaxReturn(0, $upload->getErrorMsg(), 0);
     } else {
         //取得成功上传的文件信息
         $uploadList = $upload->getUploadFileInfo();
         if ($_REQUEST['addwater']) {
             //$this->Config['watermark_enable']  $_REQUEST['addwater']
             import("@.ORG.Image");
             Image::watermark($uploadList[0]['savepath'] . $uploadList[0]['savename'], '', $this->Config);
         }
         $imagearr = explode(',', 'jpg,gif,png,jpeg,bmp,ttf,tif');
         $data = array();
         $model = M('Attachment');
         //保存当前数据对象
         $data['moduleid'] = $_REQUEST['moduleid'];
         $data['catid'] = 0;
         $data['userid'] = $_REQUEST['userid'];
         $data['filename'] = $uploadList[0]['name'];
         $data['filepath'] = __ROOT__ . substr($uploadList[0]['savepath'] . strtolower($uploadList[0]['savename']), 1);
         $data['filesize'] = $uploadList[0]['size'];
         $data['fileext'] = strtolower($uploadList[0]['extension']);
         $data['isimage'] = in_array($data['fileext'], $imagearr) ? 1 : 0;
         $data['isthumb'] = intval($_REQUEST['isthumb']);
         $data['createtime'] = time();
         $data['uploadip'] = get_client_ip();
         $aid = $model->add($data);
         $returndata['aid'] = $aid;
         $returndata['filepath'] = $data['filepath'];
         $returndata['fileext'] = $data['fileext'];
         $returndata['isimage'] = $data['isimage'];
         $returndata['filename'] = $data['filename'];
         $returndata['filesize'] = $data['filesize'];
         $this->ajaxReturn($returndata, L('upload_ok'), '1');
     }
 }
开发者ID:anywn3773,项目名称:gzsrex,代码行数:54,代码来源:AttachmentAction.class.php

示例12: displayFormat

 /**
  * Gets the media item file in the correct format and passes it through PHP
  *
  * @param array $item
  * @param string $format
  * @return bool
  */
 protected function displayFormat(array $item, $format)
 {
     if ($format == 'thumb') {
         $file = $item['path_fs'] . '/' . $item['thumbnail'];
     } else {
         if ($item['type'] == 'image') {
             /**
              * Get either full or medium sized image, however no large than
              * the specified max width.
              */
             $imgPath = $item['path_fs'] . '/' . $item['filename'];
             if (is_file($imgPath)) {
                 list($imgWidth) = getimagesize($imgPath);
                 $maxWidth = $this->_config->get('media/max_image_width');
                 if ($format == 'medium') {
                     // Display the medium size image no wider than the themes content
                     try {
                         $contentWidth = $this->_theme->getDetail('contentWidth');
                     } catch (Theme_DetailNoExist $e) {
                         $contentWidth = 500;
                     }
                     if ($contentWidth < $maxWidth) {
                         $maxWidth = $contentWidth;
                     }
                 }
                 // Resize and add watermark if needed
                 $wmPath = $this->_zula->getDir('uploads') . '/media/wm.png';
                 if ($imgWidth <= $maxWidth && !is_file($wmPath)) {
                     $file = $imgPath;
                 } else {
                     $file = $this->_zula->getDir('tmp') . "/media/max{$maxWidth}-" . pathinfo($item['filename'], PATHINFO_BASENAME);
                     if (!is_file($file)) {
                         $image = new Image($imgPath);
                         $image->resize($maxWidth, null, false);
                         if (is_file($wmPath)) {
                             $image->watermark($wmPath, $this->_config->get('media/wm_position'));
                         }
                         $image->save($file);
                     }
                 }
             }
         } else {
             if ($format == 'stream' && $item['type'] == 'audio' || $item['type'] == 'video') {
                 $file = $item['path_fs'] . '/' . $item['filename'];
             }
         }
     }
     if (isset($file) && is_file($file)) {
         zula_readfile($file);
         return false;
     } else {
         if ($format == 'thumb') {
             zula_readfile(zula_get_icon('misc/missing_' . $item['type'], null, false));
             return false;
         } else {
             if ($item['type'] == 'image') {
                 // Display default icon
                 zula_readfile(zula_get_icon('misc/no_file', null, false));
                 return false;
             } else {
                 throw new Module_ControllerNoExist();
             }
         }
     }
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:72,代码来源:view.php

示例13: Image

<?php

require_once 'image.php';
if (isset($_POST['submit'])) {
    $imagepath = 'D:/www/phpweb20/public/test/image/' . $_FILES['image']['name'];
    move_uploaded_file($_FILES['image']['tmp_name'], $imagepath);
    $image = new Image($imagepath);
    $image->thumb(400, 400);
    $image->watermark();
}
?>

<form action="" method="post" enctype="multipart/form-data">
	<input type="file" name="image" /><br />
	<input type="submit" name="submit" value="Submit!" />
</form>
开发者ID:kalroot,项目名称:phpweb20demo,代码行数:16,代码来源:file.php

示例14: actionAtme

 public function actionAtme()
 {
     $this->pageTitle = '最爱@我';
     $SAEOAuth = Yii::app()->SAEOAuth;
     $client = $SAEOAuth->getSinaClient();
     $sina_id = $SAEOAuth->getUserID();
     if (empty($sina_id)) {
         $this->actionLogin();
     }
     $sina_info = $client->show_user($sina_id);
     #print_r($sina_info);
     $count = 200;
     $page = 1;
     $ms = array();
     while ($tmp <= 1) {
         $tmp = $client->mentions($page, $count);
         $ms += $tmp;
         $tmp_count = count($tmp);
         $page++;
     }
     $sum = count($ms);
     if (!empty($ms)) {
         foreach ($ms as $one) {
             $user = $one['user'];
             $uid = $user['id'];
             if ($uid == $sina_id) {
                 continue;
             }
             $user_list[$uid] = $user;
             $user_count_list[$uid]++;
         }
     }
     if (!empty($user_count_list)) {
         arsort($user_count_list);
         $size = 10;
         $tmp = array_chunk($user_count_list, $size, true);
         $user_count_list = $tmp[0];
     }
     if (!empty($user_count_list)) {
         foreach ($user_count_list as $uid => $count) {
             $user = $user_list[$uid];
             $sex_count[$user['gender']]++;
             $weibo_count[$user['gender']] += $count;
         }
     }
     //统计
     if (!empty($sex_count)) {
         $gender = $sina_info['gender'];
         $gender_other = $sina_info['gender'] == 'm' ? 'f' : 'm';
         //比例
         $gender_persent = 100 * $sex_count[$gender] / ($sex_count[$gender] + $sex_count[$gender_other]);
     }
     $message = $this->getPersentMessage($gender_persent);
     $random_text = $this->getRandomText();
     if (count($user_count_list) >= 3) {
         foreach ($user_count_list as $uid => $count) {
             $user = $user_list[$uid];
             $text_arr[] = $user['name'];
             if (count($img_arr) < 3) {
                 $img_arr[] = array('img_url' => $user['profile_image_url'], 'name' => $user['name']);
                 $ids_arr[] = $uid;
                 //微博内容
                 $send_weibo_text .= "@{$user[name]} ";
             } else {
                 $text_arr_other[] = $user['name'];
             }
         }
         #include('saedisk.class.php');
         #$SaeDisk = new SaeDisk();
         $file_name = "atme_{$ids_arr[0]}_{$ids_arr[1]}_{$ids_arr[2]}";
         if (0 and $SaeDisk->file_exists($file_name)) {
             $weibo_img = $SaeDisk->getWebUrl($file_name);
         } else {
             Yii::import('application.extensions.image.Image');
             $app_root = Yii::getPathOfAlias('webroot');
             $atme_img = $app_root . '/images/atme.jpg';
             $image_base = new Image($atme_img);
             //实例化SaeImage并取得最大一张图片的大小,稍后用于设定合成后图片的画布大小
             $tmp_path = Yii::app()->runtimePath;
             //写入临时文件
             if (!empty($image_base)) {
                 $new_filename = $tmp_path . '/' . $file_name;
                 $image_base->save($new_filename);
                 if (!empty($img_arr)) {
                     $img_zuobiao = array('0' => array('left' => 188, 'top' => 53), '1' => array('left' => 304, 'top' => 106), '2' => array('left' => 64, 'top' => 138));
                     $text_zuobiao = array('0' => array('left' => 180, 'top' => 40), '1' => array('left' => 300, 'top' => 98), '2' => array('left' => 64, 'top' => 128));
                     $textAttr = array("fontName" => Yii_Font_MicroHei, "fontSize" => 12, "fontColor" => "#333333");
                     foreach ($img_arr as $key => $one) {
                         $name = $one['name'];
                         $img_url = $one['img_url'];
                         $img_data = $this->file_get_contents($img_url);
                         $img_filename = $tmp_path . '/' . md5($img_url);
                         $avatra[] = file_put_contents($img_filename, $img_data);
                         //头像
                         $image_avatra = new Image($img_filename);
                         $zuobiao = $img_zuobiao[$key];
                         $left = $zuobiao['left'];
                         $top = $zuobiao['top'];
                         $image_base->watermark($image_avatra, 100, $left, $top);
                         $zuobiao2 = $text_zuobiao[$key];
//.........这里部分代码省略.........
开发者ID:vangogogo,项目名称:justsns,代码行数:101,代码来源:WeiboController.php

示例15: applyWatermark

 /**
  * Получает путь к картинке и накладывает водяные знаки
  */
 private function applyWatermark($filename, $wm_filename)
 {
     $this->log("==> applyWatermark()", 2);
     $wm_fullname = DIR_IMAGE . $wm_filename;
     $fullname = DIR_IMAGE . $filename;
     if (is_file($wm_fullname) && is_file($fullname)) {
         // Получим расширение файла
         $info = pathinfo($filename);
         $extension = $info['extension'];
         // Создаем объект картинка из водяного знака и получаем информацию о картинке
         $image = new Image($fullname);
         if (version_compare($this->config->get('exchange1c_CMS_version'), '2.0.3.1', '>')) {
             $image->watermark(new Image($wm_fullname));
         } else {
             $image->watermark($wm_fullname);
         }
         // Формируем название для файла с наложенным водяным знаком
         $new_image = utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '_wm.' . $extension;
         // Сохраняем картинку с водяным знаком
         $image->save(DIR_IMAGE . $new_image);
         $this->log("> Файл с водяным знаком " . $new_image);
         $this->log("[i] Удален старый файл: " . $filename, 2);
         return $new_image;
     } else {
         return $filename;
     }
 }
开发者ID:KirilLoveVE,项目名称:opencart2-exchange1c,代码行数:30,代码来源:exchange1c.php


注:本文中的Image::watermark方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。