本文整理汇总了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;