當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。