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


PHP phpthumb_functions::nonempty_min方法代码示例

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


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

示例1: CalculateThumbnailDimensions

 function CalculateThumbnailDimensions()
 {
     $this->DebugMessage('CalculateThumbnailDimensions() starting with [W,H,sx,sy,sw,sh] initially set to [' . $this->source_width . ',' . $this->source_height . ',' . $this->sx . ',' . $this->sy . ',' . $this->sw . ',' . $this->sh . ']', __FILE__, __LINE__);
     //echo $this->source_width.'x'.$this->source_height.'<hr>';
     $this->thumbnailCropX = $this->sx ? $this->sx >= 2 ? $this->sx : round($this->sx * $this->source_width) : 0;
     //echo $this->thumbnailCropX.'<br>';
     $this->thumbnailCropY = $this->sy ? $this->sy >= 2 ? $this->sy : round($this->sy * $this->source_height) : 0;
     //echo $this->thumbnailCropY.'<br>';
     $this->thumbnailCropW = $this->sw ? $this->sw >= 2 ? $this->sw : round($this->sw * $this->source_width) : $this->source_width;
     //echo $this->thumbnailCropW.'<br>';
     $this->thumbnailCropH = $this->sh ? $this->sh >= 2 ? $this->sh : round($this->sh * $this->source_height) : $this->source_height;
     //echo $this->thumbnailCropH.'<hr>';
     // limit source area to original image area
     $this->thumbnailCropW = max(1, min($this->thumbnailCropW, $this->source_width - $this->thumbnailCropX));
     $this->thumbnailCropH = max(1, min($this->thumbnailCropH, $this->source_height - $this->thumbnailCropY));
     $this->DebugMessage('CalculateThumbnailDimensions() starting with [x,y,w,h] initially set to [' . $this->thumbnailCropX . ',' . $this->thumbnailCropY . ',' . $this->thumbnailCropW . ',' . $this->thumbnailCropH . ']', __FILE__, __LINE__);
     if ($this->zc && $this->w && $this->h) {
         // Zoom Crop
         // retain proportional resizing we did above, but crop off larger dimension so smaller
         // dimension fully fits available space
         $scaling_X = $this->source_width / $this->w;
         $scaling_Y = $this->source_height / $this->h;
         if ($scaling_X > $scaling_Y) {
             // some of the width will need to be cropped
             $allowable_width = $this->source_width / $scaling_X * $scaling_Y;
             $this->thumbnailCropW = round($allowable_width);
             $this->thumbnailCropX = round(($this->source_width - $allowable_width) / 2);
         } elseif ($scaling_Y > $scaling_X) {
             // some of the height will need to be cropped
             $allowable_height = $this->source_height / $scaling_Y * $scaling_X;
             $this->thumbnailCropH = round($allowable_height);
             $this->thumbnailCropY = round(($this->source_height - $allowable_height) / 2);
         } else {
             // image fits perfectly, no cropping needed
         }
         $this->thumbnail_width = $this->w;
         $this->thumbnail_height = $this->h;
         $this->thumbnail_image_width = $this->thumbnail_width;
         $this->thumbnail_image_height = $this->thumbnail_height;
     } elseif ($this->iar && $this->w && $this->h) {
         // Ignore Aspect Ratio
         // stretch image to fit exactly 'w' x 'h'
         $this->thumbnail_width = $this->w;
         $this->thumbnail_height = $this->h;
         $this->thumbnail_image_width = $this->thumbnail_width;
         $this->thumbnail_image_height = $this->thumbnail_height;
     } else {
         $original_aspect_ratio = $this->thumbnailCropW / $this->thumbnailCropH;
         if ($this->aoe) {
             if ($this->w && $this->h) {
                 $maxwidth = min($this->w, $this->h * $original_aspect_ratio);
                 $maxheight = min($this->h, $this->w / $original_aspect_ratio);
             } elseif ($this->w) {
                 $maxwidth = $this->w;
                 $maxheight = $this->w / $original_aspect_ratio;
             } elseif ($this->h) {
                 $maxwidth = $this->h * $original_aspect_ratio;
                 $maxheight = $this->h;
             } else {
                 $maxwidth = $this->thumbnailCropW;
                 $maxheight = $this->thumbnailCropH;
             }
         } else {
             $maxwidth = phpthumb_functions::nonempty_min($this->w, $this->thumbnailCropW, $this->config_output_maxwidth);
             $maxheight = phpthumb_functions::nonempty_min($this->h, $this->thumbnailCropH, $this->config_output_maxheight);
             //echo $maxwidth.'x'.$maxheight.'<br>';
             $maxwidth = min($maxwidth, $maxheight * $original_aspect_ratio);
             $maxheight = min($maxheight, $maxwidth / $original_aspect_ratio);
             //echo $maxwidth.'x'.$maxheight.'<hr>';
         }
         $this->thumbnail_image_width = $maxwidth;
         $this->thumbnail_image_height = $maxheight;
         $this->thumbnail_width = $maxwidth;
         $this->thumbnail_height = $maxheight;
         $this->FixedAspectRatio();
     }
     $this->thumbnail_width = max(1, floor($this->thumbnail_width));
     $this->thumbnail_height = max(1, floor($this->thumbnail_height));
     return true;
 }
开发者ID:notzen,项目名称:exponent-cms,代码行数:80,代码来源:phpthumb.class.php


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