當前位置: 首頁>>代碼示例>>PHP>>正文


PHP phpthumb_functions::ScaleToFitInBox方法代碼示例

本文整理匯總了PHP中phpthumb_functions::ScaleToFitInBox方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpthumb_functions::ScaleToFitInBox方法的具體用法?PHP phpthumb_functions::ScaleToFitInBox怎麽用?PHP phpthumb_functions::ScaleToFitInBox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在phpthumb_functions的用法示例。


在下文中一共展示了phpthumb_functions::ScaleToFitInBox方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ApplyFilters


//.........這裏部分代碼省略.........
                             $this->DebugMessage('ImageCreateFromStringReplacement() failed for "' . $filename . '"', __FILE__, __LINE__);
                         }
                     } else {
                         $this->DebugMessage('Cannot open overlay file "' . $filename . '"', __FILE__, __LINE__);
                     }
                     break;
                 case 'wmi':
                     // WaterMarkImage
                     @(list($filename, $alignment, $opacity, $margin['x'], $margin['y'], $rotate_angle) = explode('|', $parameter, 6));
                     // $margin can be pixel margin or percent margin if $alignment is text, or max width/height if $alignment is position like "50x75"
                     $alignment = $alignment ? $alignment : 'BR';
                     $opacity = strlen($opacity) ? intval($opacity) : 50;
                     $rotate_angle = strlen($rotate_angle) ? intval($rotate_angle) : 0;
                     if (!preg_match('#^([0-9\\.\\-]*)x([0-9\\.\\-]*)$#i', $alignment, $matches)) {
                         $margins = array('x', 'y');
                         foreach ($margins as $xy) {
                             $margin[$xy] = strlen($margin[$xy]) ? $margin[$xy] : 5;
                             if ($margin[$xy] > 0 && $margin[$xy] < 1) {
                                 $margin[$xy] = min(0.499, $margin[$xy]);
                             } elseif ($margin[$xy] > -1 && $margin[$xy] < 0) {
                                 $margin[$xy] = max(-0.499, $margin[$xy]);
                             }
                         }
                     }
                     $filename = $this->ResolveFilenameToAbsolute($filename);
                     if (@is_readable($filename)) {
                         if ($img_watermark = $this->ImageCreateFromFilename($filename)) {
                             if ($rotate_angle !== 0) {
                                 $phpthumbFilters->ImprovedImageRotate($img_watermark, $rotate_angle);
                             }
                             if (preg_match('#^([0-9\\.\\-]*)x([0-9\\.\\-]*)$#i', $alignment, $matches)) {
                                 $watermark_max_width = intval($margin['x'] ? $margin['x'] : ImageSX($img_watermark));
                                 $watermark_max_height = intval($margin['y'] ? $margin['y'] : ImageSY($img_watermark));
                                 $scale = phpthumb_functions::ScaleToFitInBox(ImageSX($img_watermark), ImageSY($img_watermark), $watermark_max_width, $watermark_max_height, true, true);
                                 $this->DebugMessage('Scaling watermark by a factor of ' . number_format($scale, 4), __FILE__, __LINE__);
                                 if ($scale > 1 || $scale < 1) {
                                     if ($img_watermark2 = phpthumb_functions::ImageCreateFunction($scale * ImageSX($img_watermark), $scale * ImageSY($img_watermark))) {
                                         ImageAlphaBlending($img_watermark2, false);
                                         ImageSaveAlpha($img_watermark2, true);
                                         $this->ImageResizeFunction($img_watermark2, $img_watermark, 0, 0, 0, 0, ImageSX($img_watermark2), ImageSY($img_watermark2), ImageSX($img_watermark), ImageSY($img_watermark));
                                         $img_watermark = $img_watermark2;
                                     } else {
                                         $this->DebugMessage('ImageCreateFunction(' . $scale * ImageSX($img_watermark) . ', ' . $scale * ImageSX($img_watermark) . ') failed', __FILE__, __LINE__);
                                     }
                                 }
                                 $watermark_dest_x = round($matches[1] - ImageSX($img_watermark) / 2);
                                 $watermark_dest_y = round($matches[2] - ImageSY($img_watermark) / 2);
                                 $alignment = $watermark_dest_x . 'x' . $watermark_dest_y;
                             }
                             $phpthumbFilters->WatermarkOverlay($this->gdimg_output, $img_watermark, $alignment, $opacity, $margin['x'], $margin['y']);
                             ImageDestroy($img_watermark);
                             if (isset($img_watermark2) && is_resource($img_watermark2)) {
                                 ImageDestroy($img_watermark2);
                             }
                         } else {
                             $this->DebugMessage('ImageCreateFromFilename() failed for "' . $filename . '"', __FILE__, __LINE__);
                         }
                     } else {
                         $this->DebugMessage('!is_readable(' . $filename . ')', __FILE__, __LINE__);
                     }
                     break;
                 case 'wmt':
                     // WaterMarkText
                     @(list($text, $size, $alignment, $hex_color, $ttffont, $opacity, $margin, $angle, $bg_color, $bg_opacity, $fillextend) = explode('|', $parameter, 11));
                     $text = $text ? $text : '';
                     $size = $size ? $size : 3;
開發者ID:notzen,項目名稱:exponent-cms,代碼行數:67,代碼來源:phpthumb.class.php


注:本文中的phpthumb_functions::ScaleToFitInBox方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。