本文整理匯總了PHP中phpthumb_functions::ProportionalResize方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpthumb_functions::ProportionalResize方法的具體用法?PHP phpthumb_functions::ProportionalResize怎麽用?PHP phpthumb_functions::ProportionalResize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phpthumb_functions
的用法示例。
在下文中一共展示了phpthumb_functions::ProportionalResize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ImageBorder
public function ImageBorder(&$gdimg, $border_width, $radius_x, $radius_y, $hexcolor_border)
{
$border_width = $border_width ? $border_width : 1;
$radius_x = $radius_x ? $radius_x : 0;
$radius_y = $radius_y ? $radius_y : 0;
$output_width = ImageSX($gdimg);
$output_height = ImageSY($gdimg);
list($new_width, $new_height) = phpthumb_functions::ProportionalResize($output_width, $output_height, $output_width - max($border_width * 2, $radius_x), $output_height - max($border_width * 2, $radius_y));
$offset_x = $radius_x ? $output_width - $new_width - $radius_x : 0;
$offset_y = $radius_y ? $output_height - $new_height - $radius_y : 0;
//header('Content-Type: image/png');
//ImagePNG($gdimg);
//exit;
if ($gd_border_canvas = phpthumb_functions::ImageCreateFunction($output_width, $output_height)) {
ImageSaveAlpha($gd_border_canvas, true);
ImageAlphaBlending($gd_border_canvas, false);
$color_background = phpthumb_functions::ImageColorAllocateAlphaSafe($gd_border_canvas, 255, 255, 255, 127);
ImageFilledRectangle($gd_border_canvas, 0, 0, $output_width, $output_height, $color_background);
$color_border = phpthumb_functions::ImageHexColorAllocate($gd_border_canvas, phpthumb_functions::IsHexColor($hexcolor_border) ? $hexcolor_border : '000000');
for ($i = 0; $i < $border_width; $i++) {
ImageLine($gd_border_canvas, floor($offset_x / 2) + $radius_x, $i, $output_width - $radius_x - ceil($offset_x / 2), $i, $color_border);
// top
ImageLine($gd_border_canvas, floor($offset_x / 2) + $radius_x, $output_height - 1 - $i, $output_width - $radius_x - ceil($offset_x / 2), $output_height - 1 - $i, $color_border);
// bottom
ImageLine($gd_border_canvas, floor($offset_x / 2) + $i, $radius_y, floor($offset_x / 2) + $i, $output_height - $radius_y, $color_border);
// left
ImageLine($gd_border_canvas, $output_width - 1 - $i - ceil($offset_x / 2), $radius_y, $output_width - 1 - $i - ceil($offset_x / 2), $output_height - $radius_y, $color_border);
// right
}
if ($radius_x && $radius_y) {
// PHP bug: ImageArc() with thicknesses > 1 give bad/undesirable/unpredicatable results
// Solution: Draw multiple 1px arcs side-by-side.
// Problem: parallel arcs give strange/ugly antialiasing problems
// Solution: draw non-parallel arcs, from one side of the line thickness at the start angle
// to the opposite edge of the line thickness at the terminating angle
for ($thickness_offset = 0; $thickness_offset < $border_width; $thickness_offset++) {
ImageArc($gd_border_canvas, floor($offset_x / 2) + 1 + $radius_x, $thickness_offset - 1 + $radius_y, $radius_x * 2, $radius_y * 2, 180, 270, $color_border);
// top-left
ImageArc($gd_border_canvas, $output_width - $radius_x - 1 - ceil($offset_x / 2), $thickness_offset - 1 + $radius_y, $radius_x * 2, $radius_y * 2, 270, 360, $color_border);
// top-right
ImageArc($gd_border_canvas, $output_width - $radius_x - 1 - ceil($offset_x / 2), $output_height - $thickness_offset - $radius_y, $radius_x * 2, $radius_y * 2, 0, 90, $color_border);
// bottom-right
ImageArc($gd_border_canvas, floor($offset_x / 2) + 1 + $radius_x, $output_height - $thickness_offset - $radius_y, $radius_x * 2, $radius_y * 2, 90, 180, $color_border);
// bottom-left
}
if ($border_width > 1) {
for ($thickness_offset = 0; $thickness_offset < $border_width; $thickness_offset++) {
ImageArc($gd_border_canvas, floor($offset_x / 2) + $thickness_offset + $radius_x, $radius_y, $radius_x * 2, $radius_y * 2, 180, 270, $color_border);
// top-left
ImageArc($gd_border_canvas, $output_width - $thickness_offset - $radius_x - 1 - ceil($offset_x / 2), $radius_y, $radius_x * 2, $radius_y * 2, 270, 360, $color_border);
// top-right
ImageArc($gd_border_canvas, $output_width - $thickness_offset - $radius_x - 1 - ceil($offset_x / 2), $output_height - $radius_y, $radius_x * 2, $radius_y * 2, 0, 90, $color_border);
// bottom-right
ImageArc($gd_border_canvas, floor($offset_x / 2) + $thickness_offset + $radius_x, $output_height - $radius_y, $radius_x * 2, $radius_y * 2, 90, 180, $color_border);
// bottom-left
}
}
}
$this->phpThumbObject->ImageResizeFunction($gd_border_canvas, $gdimg, floor(($output_width - $new_width) / 2), round(($output_height - $new_height) / 2), 0, 0, $new_width, $new_height, $output_width, $output_height);
ImageDestroy($gdimg);
$gdimg = phpthumb_functions::ImageCreateFunction($output_width, $output_height);
ImageSaveAlpha($gdimg, true);
ImageAlphaBlending($gdimg, false);
$gdimg_color_background = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, 255, 255, 255, 127);
ImageFilledRectangle($gdimg, 0, 0, $output_width, $output_height, $gdimg_color_background);
ImageCopy($gdimg, $gd_border_canvas, 0, 0, 0, 0, $output_width, $output_height);
//$gdimg = $gd_border_canvas;
ImageDestroy($gd_border_canvas);
return true;
} else {
$this->DebugMessage('FAILED: $gd_border_canvas = phpthumb_functions::ImageCreateFunction(' . $output_width . ', ' . $output_height . ')', __FILE__, __LINE__);
}
return false;
}