本文整理汇总了PHP中WideImage_Image::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP WideImage_Image::copy方法的具体用法?PHP WideImage_Image::copy怎么用?PHP WideImage_Image::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WideImage_Image
的用法示例。
在下文中一共展示了WideImage_Image::copy方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Rotates and mirrors and image properly based on current orientation value
*
* @param WideImage_Image $img
* @param int $orientation
* @return WideImage_Image
*/
function execute($img, $orientation)
{
switch ($orientation) {
case 2:
return $img->mirror();
break;
case 3:
return $img->rotate(180);
break;
case 4:
return $img->rotate(180)->mirror();
break;
case 5:
return $img->rotate(90)->mirror();
break;
case 6:
return $img->rotate(90);
break;
case 7:
return $img->rotate(-90)->mirror();
break;
case 8:
return $img->rotate(-90);
break;
default:
return $img->copy();
}
}
示例2: execute
/**
* Returns rotated image
*
* @param WideImage_Image $image
* @param numeric $angle
* @param int $bgColor
* @param bool $ignoreTransparent
* @return WideImage_Image
*/
function execute($image, $angle, $bgColor, $ignoreTransparent)
{
$angle = -floatval($angle);
if ($angle < 0) {
$angle = 360 + $angle;
}
$angle = $angle % 360;
if ($angle == 0) {
return $image->copy();
}
if ($bgColor === null) {
if ($image->isTransparent()) {
$bgColor = $image->getTransparentColor();
} else {
$tc = array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127);
if ($image->isTrueColor()) {
$bgColor = $image->getExactColorAlpha($tc);
if ($bgColor == -1) {
$bgColor = $image->allocateColorAlpha($tc);
}
} else {
$bgColor = $image->getExactColor($tc);
if ($bgColor == -1) {
$bgColor = $image->allocateColor($tc);
}
}
}
}
return new WideImage_TrueColorImage(imagerotate($image->getHandle(), $angle, $bgColor, $ignoreTransparent));
}
示例3: execute
/**
* Executes imagegammacorrect()
*
* @param WideImage_Image $image
* @param numeric $input_gamma
* @param numeric $output_gamma
* @return WideImage_TrueColorImage
*/
function execute($image, $input_gamma, $output_gamma)
{
$new = $image->copy();
if (!imagegammacorrect($new->getHandle(), $input_gamma, $output_gamma)) {
throw new WideImage_GDFunctionResultException("imagegammacorrect() returned false");
}
return $new;
}
示例4: execute
/**
* Returns a mirrored image
*
* @param WideImage_Image $image
* @return WideImage_Image
*/
function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
for ($x = 0; $x < $width; $x++) {
imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height);
}
return $new;
}
示例5: execute
/**
* Returns a flipped image
*
* @param WideImage_Image $image
* @return WideImage_Image
*/
function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
for ($y = 0; $y < $height; $y++) {
imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1);
}
return $new;
}
示例6: execute
/**
* Returns a flipped image
*
* @param WideImage_Image $image
* @return WideImage_Image
*/
function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
if ($new->isTransparent()) {
imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
}
for ($y = 0; $y < $height; $y++) {
imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1);
}
return $new;
}
示例7: execute
/**
* Returns a mirrored image
*
* @param WideImage_Image $image
* @return WideImage_Image
*/
function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
if ($new->isTransparent()) {
imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
}
for ($x = 0; $x < $width; $x++) {
imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height);
}
return $new;
}
示例8: execute
/**
* Returns a mirrored image
*
* @param WideImage_Image $image
* @return WideImage_Image
*/
function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
if ($new->isTransparent()) {
imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
}
for ($x = 0; $x < $width; $x++) {
if (!imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height)) {
throw new WideImage_GDFunctionResultException("imagecopy() returned false");
}
}
return $new;
}
示例9: execute
/**
* Returns a flipped image.
*
* @param WideImage_Image $image
*
* @return WideImage_Image
*/
public function execute($image)
{
$new = $image->copy();
$width = $image->getWidth();
$height = $image->getHeight();
if ($new->isTransparent()) {
imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor());
}
for ($y = 0; $y < $height; ++$y) {
if (!imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1)) {
throw new WideImage_GDFunctionResultException('imagecopy() returned false');
}
}
return $new;
}
示例10: execute
/**
* Returns rotated image
*
* @param WideImage_Image $image
* @param numeric $angle
* @param int $bgColor
* @param bool $ignoreTransparent
* @return WideImage_Image
*/
function execute($image, $angle, $bgColor, $ignoreTransparent)
{
$angle = -floatval($angle);
if ($angle < 0) {
$angle = 360 + $angle;
}
$angle = $angle % 360;
if ($angle == 0) {
return $image->copy();
}
$image = $image->asTrueColor();
if ($bgColor === null) {
$bgColor = $image->getTransparentColor();
if ($bgColor == -1) {
$bgColor = $image->allocateColorAlpha(255, 255, 255, 127);
imagecolortransparent($image->getHandle(), $bgColor);
}
}
return new WideImage_TrueColorImage(imagerotate($image->getHandle(), $angle, $bgColor, $ignoreTransparent));
}
示例11: execute
/**
* @param WideImage_Image $image
* @param int $radius
* @param int $color
* @param int $smoothness
* @return WideImage_Image
*/
function execute($image, $radius, $color, $smoothness, $corners)
{
if ($smoothness < 1) {
$sample_ratio = 1;
} elseif ($smoothness > 16) {
$sample_ratio = 16;
} else {
$sample_ratio = $smoothness;
}
$corner = WideImage::createTrueColorImage($radius * $sample_ratio, $radius * $sample_ratio);
if ($color === null) {
imagepalettecopy($corner->getHandle(), $image->getHandle());
$bg_color = $corner->allocateColor(0, 0, 0);
$corner->fill(0, 0, $bg_color);
$fg_color = $corner->allocateColor(255, 255, 255);
$corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color);
$corner = $corner->resize($radius, $radius);
$result = $image->asTrueColor();
$tc = $result->getTransparentColor();
if ($tc == -1) {
$tc = $result->allocateColorAlpha(255, 255, 255, 127);
imagecolortransparent($result->getHandle(), $tc);
$result->setTransparentColor($tc);
}
if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) {
$result = $result->applyMask($corner, -1, -1);
}
$corner = $corner->rotate(90);
if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) {
$result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100);
}
$corner = $corner->rotate(90);
if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) {
$result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100);
}
$corner = $corner->rotate(90);
if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) {
$result = $result->applyMask($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100);
}
return $result;
} else {
$bg_color = $color;
$corner->fill(0, 0, $bg_color);
$fg_color = $corner->allocateColorAlpha(127, 127, 127, 127);
$corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color);
$corner = $corner->resize($radius, $radius);
$result = $image->copy();
if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) {
$result = $result->merge($corner, -1, -1, 100);
}
$corner = $corner->rotate(90);
if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) {
$result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100);
}
$corner = $corner->rotate(90);
if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) {
$result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100);
}
$corner = $corner->rotate(90);
if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) {
$result = $result->merge($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100);
}
return $result;
}
}
示例12: execute
/**
* Executes the auto-crop operation on the $img
*
* @param WideImage_Image $img
* @param int $rgb_threshold The difference in RGB from $base_color
* @param int $pixel_cutoff The number of pixels on each border that must be over $rgb_threshold
* @param int $base_color The color that will get cropped
* @return WideImage_Image resulting auto-cropped image
*/
function execute($img, $margin, $rgb_threshold, $pixel_cutoff, $base_color)
{
$margin = intval($margin);
$rgb_threshold = intval($rgb_threshold);
if ($rgb_threshold < 0) {
$rgb_threshold = 0;
}
$pixel_cutoff = intval($pixel_cutoff);
if ($pixel_cutoff <= 1) {
$pixel_cutoff = 1;
}
if ($base_color === null) {
$rgb_base = $img->getRGBAt(0, 0);
} else {
if ($base_color < 0) {
return $img->copy();
}
$rgb_base = $img->getColorRGB($base_color);
}
$cut_rect = array('left' => 0, 'top' => 0, 'right' => $img->getWidth() - 1, 'bottom' => $img->getHeight() - 1);
for ($y = 0; $y <= $cut_rect['bottom']; $y++) {
$count = 0;
for ($x = 0; $x <= $cut_rect['right']; $x++) {
$rgb = $img->getRGBAt($x, $y);
$diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']);
if ($diff > $rgb_threshold) {
$count++;
if ($count >= $pixel_cutoff) {
$cut_rect['top'] = $y;
break 2;
}
}
}
}
for ($y = $img->getHeight() - 1; $y >= $cut_rect['top']; $y--) {
$count = 0;
for ($x = 0; $x <= $cut_rect['right']; $x++) {
$rgb = $img->getRGBAt($x, $y);
$diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']);
if ($diff > $rgb_threshold) {
$count++;
if ($count >= $pixel_cutoff) {
$cut_rect['bottom'] = $y;
break 2;
}
}
}
}
for ($x = 0; $x <= $cut_rect['right']; $x++) {
$count = 0;
for ($y = $cut_rect['top']; $y <= $cut_rect['bottom']; $y++) {
$rgb = $img->getRGBAt($x, $y);
$diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']);
if ($diff > $rgb_threshold) {
$count++;
if ($count >= $pixel_cutoff) {
$cut_rect['left'] = $x;
break 2;
}
}
}
}
for ($x = $cut_rect['right']; $x >= $cut_rect['left']; $x--) {
$count = 0;
for ($y = $cut_rect['top']; $y <= $cut_rect['bottom']; $y++) {
$rgb = $img->getRGBAt($x, $y);
$diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']);
if ($diff > $rgb_threshold) {
$count++;
if ($count >= $pixel_cutoff) {
$cut_rect['right'] = $x;
break 2;
}
}
}
}
$cut_rect = array('left' => $cut_rect['left'] - $margin, 'top' => $cut_rect['top'] - $margin, 'right' => $cut_rect['right'] + $margin, 'bottom' => $cut_rect['bottom'] + $margin);
if ($cut_rect['left'] < 0) {
$cut_rect['left'] = 0;
}
if ($cut_rect['top'] < 0) {
$cut_rect['top'] = 0;
}
if ($cut_rect['right'] >= $img->getWidth()) {
$cut_rect['right'] = $img->getWidth() - 1;
}
if ($cut_rect['bottom'] >= $img->getHeight()) {
$cut_rect['bottom'] = $img->getHeight() - 1;
}
return $img->crop($cut_rect['left'], $cut_rect['top'], $cut_rect['right'] - $cut_rect['left'] + 1, $cut_rect['bottom'] - $cut_rect['top'] + 1);
}
示例13: execute
/**
* Executes imagegammacorrect()
*
* @param WideImage_Image $image
* @param numeric $input_gamma
* @param numeric $output_gamma
* @return WideImage_TrueColorImage
*/
function execute($image, $input_gamma, $output_gamma)
{
$new = $image->copy();
imagegammacorrect($new->getHandle(), $input_gamma, $output_gamma);
return $new;
}