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


PHP image::factory方法代码示例

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


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

示例1: checkFile

 public function checkFile($file, array $config)
 {
     $driver = isset($config['imageDriversPriority']) ? image::getDriver(explode(" ", $config['imageDriversPriority'])) : "gd";
     $img = image::factory($driver, $file);
     if ($img->initError) {
         return "Unknown image format/encoding.";
     }
     return true;
 }
开发者ID:CapsuleCorpIndonesia,项目名称:elang-combo,代码行数:9,代码来源:type_img.php

示例2: makeThumb

 protected function makeThumb($file, $overwrite = true)
 {
     $img = image::factory($this->imageDriver, $file);
     // Drop files which are not images
     if ($img->initError) {
         return true;
     }
     $fimg = new fastImage($file);
     $type = $fimg->getType();
     $fimg->close();
     if ($type === false) {
         return true;
     }
     $thumb = substr($file, strlen($this->config['uploadDir']));
     $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb;
     $thumb = path::normalize($thumb);
     $thumbDir = dirname($thumb);
     if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true)) {
         return false;
     }
     if (!$overwrite && is_file($thumb)) {
         return true;
     }
     // Images with smaller resolutions than thumbnails
     if ($img->width <= $this->config['thumbWidth'] && $img->height <= $this->config['thumbHeight']) {
         // Drop only browsable types
         if (in_array($type, array("gif", "jpeg", "png"))) {
             return true;
         }
         // Resize image
     } elseif (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight'])) {
         return false;
     }
     // Save thumbnail
     $options = array('file' => $thumb);
     if ($type == "gif") {
         $type = "jpeg";
     }
     if ($type == "jpeg") {
         $options['quality'] = $this->config['jpegQuality'];
     }
     return $img->output($type, $options);
 }
开发者ID:mikegrahamjones,项目名称:kcfinder,代码行数:43,代码来源:uploader.php

示例3: makeThumb

 protected function makeThumb($file, $overwrite = true)
 {
     $img = image::factory($this->imageDriver, $file);
     // Drop files which are not images
     if ($img->initError) {
         return true;
     }
     $thumb = substr($file, strlen($this->config['uploadDir']));
     $thumb = $this->config['uploadDir'] . "/" . $this->config['thumbsDir'] . "/" . $thumb;
     $thumb = path::normalize($thumb);
     $thumbDir = dirname($thumb);
     if (!is_dir($thumbDir) && !@mkdir($thumbDir, $this->config['dirPerms'], true)) {
         return false;
     }
     if (!$overwrite && is_file($thumb)) {
         return true;
     }
     // Images with smaller resolutions than thumbnails
     if ($img->width <= $this->config['thumbWidth'] && $img->height <= $this->config['thumbHeight']) {
         list($tmp, $tmp, $type) = @getimagesize($file);
         // Drop only browsable types
         if (in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
             return true;
         }
         // Resize image
     } elseif (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight'])) {
         return false;
     }
     // Save thumbnail
     return $img->output("jpeg", array('file' => $thumb, 'quality' => $this->config['jpegQuality']));
 }
开发者ID:skullyframework,项目名称:skully-amazon-s3,代码行数:31,代码来源:uploader.php

示例4: act_thumb

 protected function act_thumb()
 {
     $this->getDir($this->get['dir'], true);
     if (!isset($this->get['file']) || !isset($this->get['dir'])) {
         $this->sendDefaultThumb();
     }
     $file = $this->get['file'];
     if (basename($file) != $file) {
         $this->sendDefaultThumb();
     }
     $file = "{$this->thumbsDir}/{$this->type}/{$this->get['dir']}/{$file}";
     if (!is_file($file) || !is_readable($file)) {
         $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file);
         if (!is_file($file) || !is_readable($file)) {
             $this->sendDefaultThumb($file);
         }
         $image = image::factory($this->imageDriver, $file);
         if ($image->initError) {
             $this->sendDefaultThumb($file);
         }
         list($tmp, $tmp, $type) = getimagesize($file);
         if (in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) && $image->width <= $this->config['thumbWidth'] && $image->height <= $this->config['thumbHeight']) {
             $mime = $type == IMAGETYPE_GIF ? "gif" : ($type == IMAGETYPE_PNG ? "png" : "jpeg");
             $mime = "image/{$mime}";
             httpCache::file($file, $mime);
         } else {
             $this->sendDefaultThumb($file);
         }
     }
     httpCache::file($file, "image/jpeg");
 }
开发者ID:Fess7,项目名称:evolution,代码行数:31,代码来源:browser.php

示例5: act_thumb

 protected function act_thumb()
 {
     if (!isset($_GET['file']) || !isset($_GET['dir']) || !$this->checkFilename($_GET['file'])) {
         $this->sendDefaultThumb();
     }
     $dir = $this->getDir();
     $file = "{$this->thumbsTypeDir}/{$_GET['dir']}/{$_GET['file']}";
     // Create thumbnail
     if (!is_file($file) || !is_readable($file)) {
         $file = "{$dir}/{$_GET['file']}";
         if (!is_file($file) || !is_readable($file)) {
             $this->sendDefaultThumb($file);
         }
         $image = image::factory($this->imageDriver, $file);
         if ($image->initError) {
             $this->sendDefaultThumb($file);
         }
         $img = new fastImage($file);
         $type = $img->getType();
         $img->close();
         if (in_array($type, array("gif", "jpeg", "png")) && $image->width <= $this->config['thumbWidth'] && $image->height <= $this->config['thumbHeight']) {
             $mime = "image/{$type}";
             httpCache::file($file, $mime);
         } else {
             $this->sendDefaultThumb($file);
         }
         // Get type from already-existing thumbnail
     } else {
         $img = new fastImage($file);
         $type = $img->getType();
         $img->close();
     }
     httpCache::file($file, "image/{$type}");
 }
开发者ID:Radius17,项目名称:kcfinder,代码行数:34,代码来源:browser.php


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