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


PHP Thumbnail::dump方法代码示例

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


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

示例1: imageGenerator

 /**
  * Image generator.
  *
  * @param string $imageFile     Image name.
  * @param int    $maxSize       Max size.
  * @param string $newFileName   New generated file name.
  * @param int    $qualitat      Quality.
  * @param string $waterMark     Watermark.
  *
  * @return array   Image resolution.
  */
 public static function imageGenerator($imageFile, $maxSize, $newFileName, $qualitat, $waterMark = '')
 {
     if (!file_exists($imageFile)) {
         return false;
     }
     // Size setter.
     list($width, $height, $type) = getimagesize($imageFile);
     $larger = $width > $height ? $width : $height;
     $smaller = $width > $height ? $height : $width;
     if ($larger <= $maxSize) {
         $newLarger = $larger;
         $newSmaller = $smaller;
     } else {
         $multiplication = $maxSize / $larger;
         $newLarger = $maxSize;
         $newSmaller = $smaller * $multiplication;
     }
     $newWidth = $width > $height ? $newLarger : $newSmaller;
     $newHeight = $width > $height ? $newSmaller : $newLarger;
     switch ($type) {
         case 1:
             $kep = imagecreatefromgif($imageFile);
             break;
         case 2:
             $kep = imagecreatefromjpeg($imageFile);
             break;
         case 3:
             $kep = imagecreatefrompng($imageFile);
             break;
     }
     $ujkep = imagecreatetruecolor($newWidth, $newHeight);
     imagecopyresampled($ujkep, $kep, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
     imagejpeg($ujkep, $newFileName, $qualitat);
     // Contructor and set source image file
     $thumb = new Thumbnail($newFileName);
     // [OPTIONAL] set maximun memory usage, default 32 MB ('32M'). (use '16M' or '32M' for litter images)
     $thumb->memory_limit = '64M';
     // [OPTIONAL] set maximun execution time, default 30 seconds ('30'). (use '60' for big images o slow server)
     $thumb->max_execution_time = 60;
     if ($waterMark != '') {
         // [OPTIONAL] set watermark source file, only PNG format [RECOMENDED ONLY WITH GD 2]
         $thumb->img_watermark = 'static/images/watermak/' . $waterMark;
     }
     // [OPTIONAL] set watermark vertical position, TOP | CENTER | BOTTOM
     $thumb->img_watermark_Valing = 'CENTER';
     // [OPTIONAL] set watermark horizonatal position, LEFT | CENTER | RIGHT
     $thumb->img_watermark_Haling = 'CENTER';
     $thumb->process();
     $newImage = $thumb->dump();
     imagejpeg($newImage, $newFileName, $qualitat);
     return array($newWidth, $newHeight);
 }
开发者ID:carriercomm,项目名称:quantum-5,代码行数:63,代码来源:ImageHelper.php


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