本文整理汇总了PHP中ImageCopy函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageCopy函数的具体用法?PHP ImageCopy怎么用?PHP ImageCopy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageCopy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: marcadeagua
function marcadeagua($img_original, $img_marcadeagua, $img_nueva, $calidad)
{
// obtener datos de la fotografia
$info_original = getimagesize($img_original);
$anchura_original = $info_original[0];
$altura_original = $info_original[1];
// obtener datos de la "marca de agua"
$info_marcadeagua = getimagesize($img_marcadeagua);
$anchura_marcadeagua = $info_marcadeagua[0];
$altura_marcadeagua = $info_marcadeagua[1];
// calcular la posición donde debe copiarse la "marca de agua" en la fotografia
/*
// Posicion: Centrado
$horizmargen = ($anchura_original - $anchura_marcadeagua)/2;
$vertmargen = ($altura_original - $altura_marcadeagua)/2;
*/
// Posicion: abajo a la izquierda
$horizmargen = 10;
$vertmargen = $altura_original - $altura_marcadeagua - 10;
// crear imagen desde el original
$original = ImageCreateFromJPEG($img_original);
ImageAlphaBlending($original, true);
// crear nueva imagen desde la marca de agua
$marcadeagua = ImageCreateFromPNG($img_marcadeagua);
// copiar la "marca de agua" en la fotografia
ImageCopy($original, $marcadeagua, $horizmargen, $vertmargen, 0, 0, $anchura_marcadeagua, $altura_marcadeagua);
// guardar la nueva imagen
ImageJPEG($original, $img_nueva, $calidad);
// cerrar las imágenes
ImageDestroy($original);
ImageDestroy($marcadeagua);
}
示例2: TransFormPicture
function TransFormPicture($inputfname, $outputfname, $transform, $backgroundcolor)
{
$img_in = ImageCreateFromPNG($inputfname);
$sizex = imagesx($img_in);
$sizey = imagesy($img_in);
$img_out = @ImageCreateTrueColor($sizex, $sizey) or die("Cannot create image handle.");
imagefill($img_out, 0, 0, hexdec($backgroundcolor));
ImageCopy($img_out, $img_in, 0, 0, 0, 0, $sizex, $sizey);
for ($x = 0; $x < $sizex; $x++) {
for ($y = 0; $y < $sizey; $y++) {
$color = imagecolorat($img_in, $x, $y);
$allcolors[dechex($color)]++;
$blue = 0xff & $color;
$green = (0xff00 & $color) >> 8;
$red = (0xff0000 & $color) >> 16;
foreach ($transform as $line) {
list($from, $to) = split("\t", $line);
list($fr, $fg, $fb) = sscanf($from, '%2x%2x%2x');
if ($blue == $fb and $red == $fr and $green == $fg) {
imagesetpixel($img_out, $x, $y, hexdec($to));
}
}
}
}
ImagePNG($img_out, "out/{$outputfname}");
imagedestroy($img_in);
imagedestroy($img_out);
print_r($allcolors);
}
示例3: showphone
function showphone()
{
global $sx, $sy, $hdiv, $vdiv, $im, $v_phone;
if ($v_phone) {
ImageCopy($im, $v_phone, $sx - 5, $sy - 1, 0, 0, 14, 10);
}
}
示例4: ApplyMask
function ApplyMask(&$image, $mask)
{
// Create copy of mask as mask may not be the same size as image
$mask_resized = ImageCreateTrueColor(ImageSX($image), ImageSY($image));
ImageCopyResampled($mask_resized, $mask, 0, 0, 0, 0, ImageSX($image), ImageSY($image), ImageSX($mask), ImageSY($mask));
// Create working temp
$mask_blendtemp = ImageCreateTrueColor(ImageSX($image), ImageSY($image));
$color_background = ImageColorAllocate($mask_blendtemp, 0, 0, 0);
ImageFilledRectangle($mask_blendtemp, 0, 0, ImageSX($mask_blendtemp), ImageSY($mask_blendtemp), $color_background);
// switch off single color alph and switch on full alpha channel
ImageAlphaBlending($mask_blendtemp, false);
ImageSaveAlpha($mask_blendtemp, true);
// loop the entire image and set pixels, this will be slow for large images
for ($x = 0; $x < ImageSX($image); $x++) {
for ($y = 0; $y < ImageSY($image); $y++) {
$RealPixel = GetPixelColor($image, $x, $y);
$MaskPixel = GrayscalePixel(GetPixelColor($mask_resized, $x, $y));
$MaskAlpha = 127 - Floor($MaskPixel['red'] / 2) * (1 - $RealPixel['alpha'] / 127);
$newcolor = ImageColorAllocateAlpha($mask_blendtemp, $RealPixel['red'], $RealPixel['green'], $RealPixel['blue'], $MaskAlpha);
ImageSetPixel($mask_blendtemp, $x, $y, $newcolor);
}
}
// don't need the mask copy anymore
ImageDestroy($mask_resized);
// switch off single color alph and switch on full alpha channel
ImageAlphaBlending($image, false);
ImageSaveAlpha($image, true);
// replace the image with the blended temp
ImageCopy($image, $mask_blendtemp, 0, 0, 0, 0, ImageSX($mask_blendtemp), ImageSY($mask_blendtemp));
ImageDestroy($mask_blendtemp);
}
示例5: watermark
function watermark($pngImage, $left = 0, $top = 0)
{
ImageAlphaBlending($this->image, true);
$layer = ImageCreateFromPNG($pngImage);
$logoW = ImageSX($layer);
$logoH = ImageSY($layer);
ImageCopy($this->image, $layer, $left, $top, 0, 0, $logoW, $logoH);
}
示例6: bar_chart
function bar_chart($question, $answers)
{
// define colors to draw the bars
$colors = array(0xff6600, 0x9900, 0x3333cc, 0xff0033, 0xffff00, 0x66ffff, 0x9900cc);
$total = array_sum($answers['votes']);
// define spacing values and other magic numbers
$padding = 5;
$line_width = 20;
$scale = $line_width * 7.5;
$bar_height = 10;
$x = $y = $padding;
// allocate a large palette for drawing, since you don't know
// the image length ahead of time
$image = ImageCreateTrueColor(150, 500);
ImageFilledRectangle($image, 0, 0, 149, 499, 0xe0e0e0);
$black = 0x0;
// print the question
$wrapped = explode("\n", wordwrap($question, $line_width));
foreach ($wrapped as $line) {
ImageString($image, 3, $x, $y, $line, $black);
$y += 12;
}
$y += $padding;
// print the answers
for ($i = 0; $i < count($answers['answer']); $i++) {
// format percentage
$percent = sprintf('%1.1f', 100 * $answers['votes'][$i] / $total);
$bar = sprintf('%d', $scale * $answers['votes'][$i] / $total);
// grab color
$c = $i % count($colors);
// handle cases with more bars than colors
$text_color = $colors[$c];
// draw bar and percentage numbers
ImageFilledRectangle($image, $x, $y, $x + $bar, $y + $bar_height, $text_color);
ImageString($image, 3, $x + $bar + $padding, $y, "{$percent}%", $black);
$y += 12;
// print answer
$wrapped = explode("\n", wordwrap($answers['answer'][$i], $line_width));
foreach ($wrapped as $line) {
ImageString($image, 2, $x, $y, $line, $black);
$y += 12;
}
$y += 7;
}
// crop image by copying it
$chart = ImageCreateTrueColor(150, $y);
ImageCopy($chart, $image, 0, 0, 0, 0, 150, $y);
// PHP 5.5+ supports
// $chart = ImageCrop($image, array('x' => 0, 'y' => 0,
// 'width' => 150, 'height' => $y));
// deliver image
header('Content-type: image/png');
ImagePNG($chart);
// clean up
ImageDestroy($image);
ImageDestroy($chart);
}
示例7: copy_image
public function copy_image($url, $logo)
{
$bwidth = imagesx($url);
$bheight = imagesy($url);
$lwidth = imagesx($logo);
$lheight = imagesy($logo);
$src_x = $bwidth - ($lwidth + 5);
$src_y = $bheight - ($lheight + 5);
ImageAlphaBlending($url, true);
ImageCopy($url, $logo, $src_x, $src_y, 0, 0, $lwidth, $lheight);
}
示例8: img_resizer
private static function img_resizer($src, $quality, $w, $h, $saveas)
{
/* v2.5 with auto crop */
$r = 1;
$e = strtolower(substr($src, strrpos($src, ".") + 1, 3));
if ($e == "jpg" || $e == "jpeg") {
$OldImage = imagecreatefromjpeg($src) or $r = 0;
} elseif ($e == "gif") {
$OldImage = ImageCreateFromGif($src) or $r = 0;
} elseif ($e == "bmp") {
$OldImage = ImageCreateFromwbmp($src) or $r = 0;
} elseif ($e == "png") {
$OldImage = ImageCreateFromPng($src) or $r = 0;
} else {
_o("No es una imagen válida! (" . $e . ") -- " . $src);
$r = 0;
}
if ($r) {
list($width, $height) = getimagesize($src);
// check if ratios match
$_ratio = array($width / $height, $w / $h);
if ($_ratio[0] != $_ratio[1]) {
// crop image
// find the right scale to use
$_scale = min((double) ($width / $w), (double) ($height / $h));
// coords to crop
$cropX = (double) ($width - $_scale * $w);
$cropY = (double) ($height - $_scale * $h);
// cropped image size
$cropW = (double) ($width - $cropX);
$cropH = (double) ($height - $cropY);
$crop = ImageCreateTrueColor($cropW, $cropH);
// crop the middle part of the image to fit proportions
ImageCopy($crop, $OldImage, 0, 0, (int) ($cropX / 2), (int) ($cropY / 2), $cropW, $cropH);
}
// do the thumbnail
$NewThumb = ImageCreateTrueColor($w, $h);
if (isset($crop)) {
// been cropped
ImageCopyResampled($NewThumb, $crop, 0, 0, 0, 0, $w, $h, $cropW, $cropH);
ImageDestroy($crop);
} else {
// ratio match, regular resize
ImageCopyResampled($NewThumb, $OldImage, 0, 0, 0, 0, $w, $h, $width, $height);
}
_ckdir($saveas);
ImageJpeg($NewThumb, $saveas, $quality);
ImageDestroy($NewThumb);
ImageDestroy($OldImage);
}
return $r;
}
示例9: imageConvolution
function imageConvolution($src, $filter, $filter_div, $offset)
{
if ($src == NULL) {
return 0;
}
$sx = imagesx($src);
$sy = imagesy($src);
$srcback = ImageCreateTrueColor($sx, $sy);
ImageAlphaBlending($srcback, false);
ImageAlphaBlending($src, false);
ImageCopy($srcback, $src, 0, 0, 0, 0, $sx, $sy);
if ($srcback == NULL) {
return 0;
}
for ($y = 0; $y < $sy; ++$y) {
for ($x = 0; $x < $sx; ++$x) {
$new_r = $new_g = $new_b = 0;
$alpha = imagecolorat($srcback, @$pxl[0], @$pxl[1]);
$new_a = $alpha >> 24;
for ($j = 0; $j < 3; ++$j) {
$yv = min(max($y - 1 + $j, 0), $sy - 1);
for ($i = 0; $i < 3; ++$i) {
$pxl = array(min(max($x - 1 + $i, 0), $sx - 1), $yv);
$rgb = imagecolorat($srcback, $pxl[0], $pxl[1]);
$new_r += ($rgb >> 16 & 0xff) * $filter[$j][$i];
$new_g += ($rgb >> 8 & 0xff) * $filter[$j][$i];
$new_b += ($rgb & 0xff) * $filter[$j][$i];
$new_a += ((0x7f000000 & $rgb) >> 24) * $filter[$j][$i];
}
}
$new_r = $new_r / $filter_div + $offset;
$new_g = $new_g / $filter_div + $offset;
$new_b = $new_b / $filter_div + $offset;
$new_a = $new_a / $filter_div + $offset;
$new_r = $new_r > 255 ? 255 : ($new_r < 0 ? 0 : $new_r);
$new_g = $new_g > 255 ? 255 : ($new_g < 0 ? 0 : $new_g);
$new_b = $new_b > 255 ? 255 : ($new_b < 0 ? 0 : $new_b);
$new_a = $new_a > 127 ? 127 : ($new_a < 0 ? 0 : $new_a);
$new_pxl = ImageColorAllocateAlpha($src, (int) $new_r, (int) $new_g, (int) $new_b, $new_a);
if ($new_pxl == -1) {
$new_pxl = ImageColorClosestAlpha($src, (int) $new_r, (int) $new_g, (int) $new_b, $new_a);
}
if ($y >= 0 && $y < $sy) {
imagesetpixel($src, $x, $y, $new_pxl);
}
}
}
imagedestroy($srcback);
return 1;
}
示例10: watermark
/**
// watermark
// source : php.net
*/
function watermark($name, $ext)
{
($hook = kleeja_run_hook('watermark_func_kljuploader')) ? eval($hook) : null;
//run hook
if (!file_exists($name)) {
return;
}
if (strpos($ext, 'jp') !== false) {
$src_img = @imagecreatefromjpeg($name);
} elseif (strpos($ext, 'png') !== false) {
$src_img = @imagecreatefrompng($name);
} elseif (strpos($ext, 'gif') !== false) {
$src_img = @imagecreatefromgif($name);
} else {
return;
}
if (file_exists('images/watermark.gif')) {
$src_logo = imagecreatefromgif('images/watermark.gif');
} elseif (file_exists('images/watermark.png')) {
$src_logo = imagecreatefrompng('images/watermark.png');
}
$bwidth = @imageSX($src_img);
$bheight = @imageSY($src_img);
$lwidth = @imageSX($src_logo);
$lheight = @imageSY($src_logo);
//fix bug for 1beta3
if ($bwidth > 160 && $bheight > 130) {
$src_x = $bwidth - ($lwidth + 5);
$src_y = $bheight - ($lheight + 5);
@ImageAlphaBlending($src_img, true);
@ImageCopy($src_img, $src_logo, $src_x, $src_y, 0, 0, $lwidth, $lheight);
if (strpos($ext, 'jp') !== false) {
@imagejpeg($src_img, $name);
} elseif (strpos($ext, 'png') !== false) {
@imagepng($src_img, $name);
} elseif (strpos($ext, 'gif') !== false) {
@imagegif($src_img, $name);
}
} else {
return false;
}
}
示例11: addBorder
/**
* Adds a border of constant width around an image
*
* @param int $border_width Width of border to add
* @author Peter Bowyer
* @return bool TRUE
* @access public
*/
function addBorder($border_width, $color = '')
{
$this->new_x = $this->img_x + 2 * $border_width;
$this->new_y = $this->img_y + 2 * $border_width;
$new_img = $this->_createImage($new_x, $new_y, $this->true_color);
$options = array('pencilColor', $color);
$color = $this->_getColor('pencilColor', $options, array(0, 0, 0));
if ($color) {
if ($this->true_color) {
$c = imagecolorresolve($this->imageHandle, $color[0], $color[1], $color[2]);
imagefill($new_img, 0, 0, $c);
} else {
imagecolorset($new_img, imagecolorat($new_img, 0, 0), $color[0], $color[1], $color[2]);
}
}
ImageCopy($new_img, $this->imageHandle, $border_width, $border_width, 0, 0, $this->img_x, $this->img_y);
$this->imageHandle = $new_img;
$this->resized = true;
return true;
}
示例12: nzshpcrt_display_preview_image
//.........这里部分代码省略.........
// select our scaling method
$scaling_method = 'cropping';
//list($source_h, $source_w) = array($source_w, $source_h);
// set both offsets to zero
$offset_x = $offset_y = 0;
// Here are the scaling methods, non-cropping causes black lines in tall images, but doesnt crop images.
switch ($scaling_method) {
case 'cropping':
// if the image is wider than it is high and at least as wide as the target width.
if ($source_h <= $source_w) {
if ($height < $width) {
$temp_h = $width / $source_w * $source_h;
} else {
$temp_w = $height / $source_h * $source_w;
}
} else {
$temp_h = $width / $source_w * $source_h;
}
break;
case 'non-cropping':
default:
if ($height < $width) {
$temp_h = $width / $source_w * $source_h;
} else {
$temp_w = $height / $source_h * $source_w;
}
break;
}
// Create temp resized image
$temp_img = ImageCreateTrueColor($temp_w, $temp_h);
$bgcolor = ImageColorAllocate($temp_img, 255, 255, 255);
ImageFilledRectangle($temp_img, 0, 0, $temp_w, $temp_h, $bgcolor);
ImageAlphaBlending($temp_img, TRUE);
ImageCopyResampled($temp_img, $src_img, 0, 0, 0, 0, $temp_w, $temp_h, $source_w, $source_h);
$dst_img = ImageCreateTrueColor($width, $height);
$bgcolor = ImageColorAllocate($dst_img, 255, 255, 255);
ImageFilledRectangle($dst_img, 0, 0, $width, $height, $bgcolor);
ImageAlphaBlending($dst_img, TRUE);
if ($imagetype[2] == IMAGETYPE_PNG || $imagetype[2] == IMAGETYPE_GIF) {
//imagecolortransparent($dst_img, $bgcolor);
}
// X & Y Offset to crop image properly
if ($temp_w < $width) {
$w1 = $width / 2 - $temp_w / 2;
} else {
if ($temp_w == $width) {
$w1 = 0;
} else {
$w1 = $width / 2 - $temp_w / 2;
}
}
if ($temp_h < $height) {
$h1 = $height / 2 - $temp_h / 2;
} else {
if ($temp_h == $height) {
$h1 = 0;
} else {
$h1 = $height / 2 - $temp_h / 2;
}
}
switch ($scaling_method) {
case 'cropping':
ImageCopy($dst_img, $temp_img, $w1, $h1, 0, 0, $temp_w, $temp_h);
break;
case 'non-cropping':
default:
示例13: apply
/**
* Applies the effect.
*/
public function apply()
{
$amount = $this->_params['amount'];
$radius = $this->_params['radius'];
$threshold = $this->_params['threshold'];
// Attempt to calibrate the parameters to Photoshop:
$amount = min($amount, 500);
$amount = $amount * 0.016;
if ($amount == 0) {
return true;
}
$radius = min($radius, 50);
$radius = $radius * 2;
$threshold = min($threshold, 255);
$radius = abs(round($radius));
// Only integers make sense.
if ($radius == 0) {
return true;
}
$img = $this->_image->_im;
$w = ImageSX($img);
$h = ImageSY($img);
$imgCanvas = ImageCreateTrueColor($w, $h);
$imgCanvas2 = ImageCreateTrueColor($w, $h);
$imgBlur = ImageCreateTrueColor($w, $h);
$imgBlur2 = ImageCreateTrueColor($w, $h);
ImageCopy($imgCanvas, $img, 0, 0, 0, 0, $w, $h);
ImageCopy($imgCanvas2, $img, 0, 0, 0, 0, $w, $h);
// Gaussian blur matrix:
//
// 1 2 1
// 2 4 2
// 1 2 1
//
//////////////////////////////////////////////////
// Move copies of the image around one pixel at the time and merge them
// with weight according to the matrix. The same matrix is simply
// repeated for higher radii.
for ($i = 0; $i < $radius; $i++) {
// up left
ImageCopy($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1);
// down right
ImageCopyMerge($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50);
// down left
ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333);
// up right
ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25);
// left
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333);
// right
ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25);
// up
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20);
// down
ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667);
// center
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50);
ImageCopy($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h);
// During the loop above the blurred copy darkens, possibly due to
// a roundoff error. Therefore the sharp picture has to go through
// the same loop to produce a similar image for comparison. This is
// not a good thing, as processing time increases heavily.
ImageCopy($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
ImageCopy($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h);
}
// Calculate the difference between the blurred pixels and the original
// and set the pixels
for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) {
$rgbOrig = ImageColorAt($imgCanvas2, $x, $y);
$rOrig = $rgbOrig >> 16 & 0xff;
$gOrig = $rgbOrig >> 8 & 0xff;
$bOrig = $rgbOrig & 0xff;
$rgbBlur = ImageColorAt($imgCanvas, $x, $y);
$rBlur = $rgbBlur >> 16 & 0xff;
$gBlur = $rgbBlur >> 8 & 0xff;
$bBlur = $rgbBlur & 0xff;
// When the masked pixels differ less from the original than
// the threshold specifies, they are set to their original
// value.
$rNew = abs($rOrig - $rBlur) >= $threshold ? max(0, min(255, $amount * ($rOrig - $rBlur) + $rOrig)) : $rOrig;
$gNew = abs($gOrig - $gBlur) >= $threshold ? max(0, min(255, $amount * ($gOrig - $gBlur) + $gOrig)) : $gOrig;
$bNew = abs($bOrig - $bBlur) >= $threshold ? max(0, min(255, $amount * ($bOrig - $bBlur) + $bOrig)) : $bOrig;
if ($rOrig != $rNew || $gOrig != $gNew || $bOrig != $bNew) {
$pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
ImageSetPixel($img, $x, $y, $pixCol);
}
}
}
//.........这里部分代码省略.........
示例14: ImageFill
// Paint the image white
ImageFill($imageOut, 0, 0, ImageColorAllocate($imageOut, 255, 255, 255));
// Draw a border in destination image
ImageRectangle($imageOut, 0, 0, $outX - 1, $outY - 1, ImageColorAllocate($imageOut, 0, 0, 0));
// Do the work
$nextX = BORDER_LEFT;
$nextY = BORDER_TOP;
foreach ($imageKeys as $imageKey) {
// Fetch the image
print " Fetch image '{$imageKey}'\n";
$image = $s3->get_object(BOOK_BUCKET, $imageKey);
// Convert it to GD format
$imageBits = ImageCreateFromString($image->body);
// Copy it to proper spot in the destination
print " Render image at {$nextX}, {$nextY}\n";
ImageCopy($imageOut, $imageBits, $nextX, $nextY, 0, 0, ImageSx($imageBits), ImageSy($imageBits));
// Draw a border around it
ImageRectangle($imageOut, $nextX, $nextY, $nextX + ImageSx($imageBits), $nextY + ImageSy($imageBits), ImageColorAllocate($imageOut, 0, 0, 0));
// Update position for next image
$nextX += THUMB_SIZE + GAP_SIZE;
if ($nextX + THUMB_SIZE > $outX) {
$nextX = BORDER_LEFT;
$nextY += THUMB_SIZE + GAP_SIZE;
}
}
// Get the bits of the destination image
$imageFileOut = tempnam('/tmp', 'aws') . '.png';
ImagePNG($imageOut, $imageFileOut, 0);
$imageBitsOut = file_get_contents($imageFileOut);
unlink($imageFileOut);
// Store the final image in S3
示例15: setClipping
/**
* Set clipping to occur
*
* Parameter array:
*
* 'x0': int X point of Upper-left corner
* 'y0': int X point of Upper-left corner
* 'x1': int X point of lower-right corner
* 'y1': int Y point of lower-right corner
*/
function setClipping($params = false)
{
if ($params === false) {
$index = count($this->_clipping) - 1;
if (isset($this->_clipping[$index])) {
$params = $this->_clipping[$index];
$canvas = $params['canvas'];
ImageCopy($canvas, $this->_canvas, min($params['x0'], $params['x1']), min($params['y0'], $params['y1']), min($params['x0'], $params['x1']), min($params['y0'], $params['y1']), abs($params['x1'] - $params['x0'] + 1), abs($params['y1'] - $params['y0'] + 1));
$this->_canvas = $canvas;
unset($this->_clipping[$index]);
}
} else {
$params['canvas'] = $this->_canvas;
if ($this->_gd2) {
$this->_canvas = ImageCreateTrueColor($this->_width, $this->_height);
if ($this->_alpha) {
ImageAlphaBlending($this->_canvas, true);
}
} else {
$this->_canvas = ImageCreate($this->_width, $this->_height);
}
if ($this->_gd2 && $this->_antialias === 'native') {
ImageAntialias($this->_canvas, true);
}
ImageCopy($this->_canvas, $params['canvas'], 0, 0, 0, 0, $this->_width, $this->_height);
$this->_clipping[count($this->_clipping)] = $params;
}
}