本文整理汇总了PHP中ImageCopyMerge函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageCopyMerge函数的具体用法?PHP ImageCopyMerge怎么用?PHP ImageCopyMerge使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageCopyMerge函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MyImageBlur
function MyImageBlur($im, $pct) {
// w00t. my very own blur function
// in GD2, there's a gaussian blur function. smarmy bastards. ;-)
$width = imagesx($im);
$height = imagesy($im);
$temp_im = ImageCreate($width, $height);
$bg = ImageColorAllocate($temp_im, 255, 255, 255);
// preserves transparency if in orig image
ImageColorTransparent($temp_im, $bg);
// fill bg
ImageFill($temp_im, 0, 0, $bg);
$distance = 1;
// emboss:
ImageCopyMerge($temp_im, $im, 0, 0, $distance, $distance, $width, $height, $pct);
ImageCopyMerge($im, $temp_im, -$distance, -$distance, 0, 0, $width, $height, $pct);
ImageFill($temp_im, 0, 0, $bg);
ImageCopyMerge($temp_im, $im, 0, $distance, $distance, 0, $width, $height, $pct);
ImageCopyMerge($im, $temp_im, $distance, 0, 0, $distance, $width, $height, $pct);
// blur:
ImageCopyMerge($temp_im, $im, 0, $distance, 0, 0, $width, $height, $pct);
ImageCopyMerge($im, $temp_im, $distance, 0, 0, 0, $width, $height, $pct);
ImageCopyMerge($temp_im, $im, 0, 0, 0, $distance, $width, $height, $pct);
ImageCopyMerge($im, $temp_im, 0, 0, $distance, 0, $width, $height, $pct);
// remove temp image
ImageDestroy($temp_im);
return $im;
}
示例2: getImage
public function getImage($objUser)
{
$img = ImageCreateFromString(base64_decode($this->getFrom('imagedata', 'data')));
$objPicture = new clsPicture($this->get('picture_id'));
if (!$objPicture->hasViewed($objUser)) {
$newImage = clsThumbnail::getNewImage();
list($newWidth, $newHeight) = clsThumbnail::getNewSize();
ImageCopyMerge($img, $newImage, $this->get('actual_width') - $newWidth, $this->get('actual_height') - $newHeight, 0, 0, $newWidth, $newHeight, 75);
ImageDestroy($newImage);
}
return $img;
}
示例3: morph
function morph($im, $sx, $sy, $w, $h)
{
$morphx = $h;
$morphy = mt_rand(3.5, 5.2);
$mx = $sx;
$my = $sy;
$mvalues = array();
for ($i = 0; $i < $morphx / 2; $i++) {
$mvalues[] = $mx - log($i + 1) * $morphy;
ImageCopyMerge($im, $im, $mvalues[$i], $my + $i, $mx, $my + $i, $w + 20, 1, 0);
}
$mvalues = array_reverse($mvalues);
$mvcount = count($mvalues);
for ($i = 0; $i < $mvcount; $i++) {
ImageCopyMerge($im, $im, $mvalues[$i], $my + $i + $mvcount, $mx, $my + $i + $mvcount, $w + 20, 1, 0);
}
}
示例4: myImageBlur
function myImageBlur($im)
{
$width = imagesx($im);
$height = imagesy($im);
$temp_im = ImageCreateTrueColor($width, $height);
$bg = ImageColorAllocate($temp_im, 150, 150, 150);
// preserves transparency if in orig image
ImageColorTransparent($temp_im, $bg);
// fill bg
ImageFill($temp_im, 0, 0, $bg);
$distance = 1;
// blur by merging with itself at different x/y offsets:
ImageCopyMerge($temp_im, $im, 0, 0, 0, $distance, $width, $height - $distance, 70);
ImageCopyMerge($im, $temp_im, 0, 0, $distance, 0, $width - $distance, $height, 70);
ImageCopyMerge($temp_im, $im, 0, $distance, 0, 0, $width, $height, 70);
ImageCopyMerge($im, $temp_im, $distance, 0, 0, 0, $width, $height, 70);
// remove temp image
ImageDestroy($temp_im);
return $im;
}
示例5: Blur
function Blur(&$imgResource, $iRadius = 1)
{
$iRadius = round(max(0, min($iRadius, 50)) * 2);
if (!$iRadius) {
return false;
}
$w = ImageSX($imgResource);
$h = ImageSY($imgResource);
if ($imgBlur = ImageCreateTrueColor($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 < $iRadius; $i++) {
ImageCopy($imgBlur, $imgResource, 0, 0, 1, 1, $w - 1, $h - 1);
// up left
ImageCopyMerge($imgBlur, $imgResource, 1, 1, 0, 0, $w, $h, 50.0);
// down right
ImageCopyMerge($imgBlur, $imgResource, 0, 1, 1, 0, $w - 1, $h, 33.33333);
// down left
ImageCopyMerge($imgBlur, $imgResource, 1, 0, 0, 1, $w, $h - 1, 25.0);
// up right
ImageCopyMerge($imgBlur, $imgResource, 0, 0, 1, 0, $w - 1, $h, 33.33333);
// left
ImageCopyMerge($imgBlur, $imgResource, 1, 0, 0, 0, $w, $h, 25.0);
// right
ImageCopyMerge($imgBlur, $imgResource, 0, 0, 0, 1, $w, $h - 1, 20.0);
// up
ImageCopyMerge($imgBlur, $imgResource, 0, 1, 0, 0, $w, $h, 16.666667);
// down
ImageCopyMerge($imgBlur, $imgResource, 0, 0, 0, 0, $w, $h, 50.0);
// center
ImageCopy($imgResource, $imgBlur, 0, 0, 0, 0, $w, $h);
}
return true;
}
return false;
}
示例6: _light_part
/**
* apply light effect for the given gd resource except the selected area <br>
* or part of given gd resource <br/>
* <b>Important:</b>
* This method require PHP to be compiled with the bundled version of the GD library.
* @param resource $virtual_image gd resource
* @param integer $x x coordinate to start point
* @param integer $y y coordinate to start point
* @param integer $width width
* @param integer $height height
* @param boolean $invert if true apply effect for selected area if false all except the selected area
* @return boolean true on success false otherwise
*/
private static function _light_part($virtual_image, $x, $y, $width, $height, $invert)
{
self::activateAlphaChannel($virtual_image);
$copy = self::gdClone($virtual_image);
if ($copy) {
self::activateAlphaChannel($copy);
if ($invert == true) {
$light_image = self::light($copy);
if ($light_image) {
return @ImageCopyMerge($virtual_image, $copy, $x, $y, $x, $y, $width, $height, 100);
}
}
if ($invert == false) {
$light_image = self::light($virtual_image);
if ($light_image) {
return @ImageCopyMerge($virtual_image, $copy, $x, $y, $x, $y, $width, $height, 100);
}
}
}
return false;
}
示例7: IO_Read
}
#-------------------------------------------------------------------------------
$Icon = IO_Read($Path);
if (Is_Error($Icon)) {
return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
if ($Messages) {
#-------------------------------------------------------------------------------
# создаём маленькую картинку с числом
$ImageSmall = @ImageCreate(9, 9);
$BgColor = ImageColorAllocate($ImageSmall, 255, 0, 0);
// красная
$TextColor = ImageColorAllocate($ImageSmall, 0, 0, 0);
// чёрный
ImageString($ImageSmall, 3, 1, -2, $Messages, $TextColor);
#-------------------------------------------------------------------------------
# готовим большую картинку
$ImageBig = @ImageCreateFromPNG($Path);
#-------------------------------------------------------------------------------
# накладываем маленькую картинку на большую
ImageCopyMerge($ImageBig, $ImageSmall, 9, 7, 0, 0, 9, 9, 100);
$Icon = ImagePNG($ImageBig);
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
return $Icon;
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
示例8: ImageCreateFromPNG
<?php
$image = ImageCreateFromPNG('/path/to/image.png');
$stamp = ImageCreateFromPNG('/path/to/stamp.png');
$margin = ['right' => 10, 'bottom' => 10];
// offset from the edge
$opacity = 50;
// between 0 and 100%
ImageCopyMerge($image, $stamp, imagesx($image) - imagesx($stamp) - $margin['right'], imagesy($image) - imagesy($stamp) - $margin['bottom'], 0, 0, imagesx($stamp), imagesy($stamp), $opacity);
示例9: Blur
public function Blur(&$gdimg, $radius = 0.5)
{
// Taken from Torstein Hønsi's phpUnsharpMask (see phpthumb.unsharp.php)
$radius = round(max(0, min($radius, 50)) * 2);
if (!$radius) {
return false;
}
$w = ImageSX($gdimg);
$h = ImageSY($gdimg);
if ($imgBlur = ImageCreateTrueColor($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++) {
ImageCopy($imgBlur, $gdimg, 0, 0, 1, 1, $w - 1, $h - 1);
// up left
ImageCopyMerge($imgBlur, $gdimg, 1, 1, 0, 0, $w, $h, 50.0);
// down right
ImageCopyMerge($imgBlur, $gdimg, 0, 1, 1, 0, $w - 1, $h, 33.33333);
// down left
ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 1, $w, $h - 1, 25.0);
// up right
ImageCopyMerge($imgBlur, $gdimg, 0, 0, 1, 0, $w - 1, $h, 33.33333);
// left
ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 0, $w, $h, 25.0);
// right
ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 1, $w, $h - 1, 20.0);
// up
ImageCopyMerge($imgBlur, $gdimg, 0, 1, 0, 0, $w, $h, 16.666667);
// down
ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 0, $w, $h, 50.0);
// center
ImageCopy($gdimg, $imgBlur, 0, 0, 0, 0, $w, $h);
}
return true;
}
return false;
}
示例10: merge
function merge($imageObject, $x, $y, $width, $height)
{
if ($this->ImageObject === null or $this->ImageObjectRef === null) {
return false;
}
// ImageAlphaBlending( $this->ImageObject, true );
imagecolortransparent($imageObject, 0);
// ImageCopy( $this->ImageObject, $imageObject, $x, $y, 0, 0, $width, $height );
ImageCopyMerge($this->ImageObject, $imageObject, $x, $y, 0, 0, $width, $height, 50);
}
示例11: make_transparent
function make_transparent()
{
$info = GetImageSize($this->source_image);
$width = $info[0];
$height = $info[1];
$mime = $info['mime'];
// What sort of image?
$type = substr(strrchr($mime, '/'), 1);
switch ($type) {
case 'jpeg':
$image_create_func = 'ImageCreateFromJPEG';
$image_save_func = 'ImageJPEG';
$new_image_ext = 'jpg';
break;
case 'png':
$image_create_func = 'ImageCreateFromPNG';
$image_save_func = 'ImagePNG';
$new_image_ext = 'png';
break;
case 'bmp':
$image_create_func = 'ImageCreateFromBMP';
$image_save_func = 'ImageBMP';
$new_image_ext = 'bmp';
break;
case 'gif':
$image_create_func = 'ImageCreateFromGIF';
$image_save_func = 'ImageGIF';
$new_image_ext = 'gif';
break;
case 'vnd.wap.wbmp':
$image_create_func = 'ImageCreateFromWBMP';
$image_save_func = 'ImageWBMP';
$new_image_ext = 'bmp';
break;
case 'xbm':
$image_create_func = 'ImageCreateFromXBM';
$image_save_func = 'ImageXBM';
$new_image_ext = 'xbm';
break;
default:
$image_create_func = 'ImageCreateFromJPEG';
$image_save_func = 'ImageJPEG';
$new_image_ext = 'jpg';
}
// Source Image
$image = $image_create_func($this->source_image);
$new_image = ImageCreateTruecolor($width, $height);
// Set a White & Transparent Background Color
$bg = ImageColorAllocateAlpha($new_image, 255, 255, 255, 127);
// (PHP 4 >= 4.3.2, PHP 5)
ImageFill($new_image, 0, 0, $bg);
// Copy and merge
ImageCopyMerge($new_image, $image, 0, 0, 0, 0, $width, $height, $this->pct);
if ($this->save_to_folder) {
if ($this->new_image_name) {
$new_name = $this->new_image_name . '.' . $new_image_ext;
} else {
$new_name = $this->new_image_name(basename($this->source_image)) . '_transparent' . '.' . $new_image_ext;
}
$save_path = $this->save_to_folder . $new_name;
} else {
/* Show the image without saving it to a folder */
header("Content-Type: " . $mime);
$image_save_func($new_image);
$save_path = '';
}
// Save image
$process = $image_save_func($new_image, $save_path) or die("There was a problem in saving the new file.");
return array('result' => $process, 'new_file_path' => $save_path);
}
示例12: Blur
function Blur($im)
{
$width = imagesx($im);
$height = imagesy($im);
$imgTmp = ImageCreateTrueColor($width, $height);
$bg = ImageColorAllocate($imgTmp, 255, 255, 255);
ImageColorTransparent($imgTmp, $bg);
ImageFill($imgTmp, 0, 0, $bg);
$d = 1;
ImageCopyMerge($imgTmp, $im, 0, 0, 0, $d, $width, $height - $d, 70);
ImageCopyMerge($im, $imgTmp, 0, 0, $d, 0, $width - $d, $height, 70);
ImageCopyMerge($imgTmp, $im, 0, $d, 0, 0, $width, $height, 70);
ImageCopyMerge($im, $imgTmp, $d, 0, 0, 0, $width, $height, 70);
ImageDestroy($imgTmp);
return $im;
}
示例13: retailler
private function retailler($nouvelle_largeur, $nouvelle_hauteur, $delta_largeur, $delta_hauteur, $reduite = false)
{
$ret = false;
if (!$this->is_null()) {
$src_r = null;
if (!strcmp($this->get_ext(), _UPLOAD_EXTENSION_JPG) || !strcmp($this->get_ext(), _UPLOAD_EXTENSION_JPEG)) {
$src_r = imagecreatefromjpeg($this->get_src());
} elseif (!strcmp($this->get_ext(), _UPLOAD_EXTENSION_PNG)) {
$src_r = imagecreatefrompng($this->get_src());
} elseif (!strcmp($this->get_ext(), _UPLOAD_EXTENSION_GIF)) {
$src_r = imagecreatefromgif($this->get_src());
}
if ($src_r) {
if ($this->get_ext() == _UPLOAD_EXTENSION_JPG || $this->get_ext() == _UPLOAD_EXTENSION_JPEG) {
$dst_r = ImageCreateTrueColor($nouvelle_largeur, $nouvelle_hauteur);
if ($dst_r) {
imagecopyresampled($dst_r, $src_r, 0, 0, $delta_largeur, $delta_hauteur, $nouvelle_largeur, $nouvelle_hauteur, $this->get_largeur() - 2 * $delta_largeur, $this->get_hauteur() - 2 * $delta_hauteur);
$qualite = $reduite ? self::qualite_jpg_reduite : self::qualite_jpg;
$ret = imagejpeg($dst_r, $this->get_src(), $qualite);
// Mise à jour des nouvelles dimensions
$this->largeur = $nouvelle_largeur;
$this->hauteur = $nouvelle_hauteur;
imagedestroy($dst_r);
}
} elseif ($this->get_ext() == _UPLOAD_EXTENSION_PNG) {
$src_alpha = $this->png_has_transparency($this->get_src());
$dst_r = ImageCreateTrueColor($nouvelle_largeur, $nouvelle_hauteur);
if ($dst_r) {
if ($src_alpha) {
imagealphablending($dst_r, false);
imagesavealpha($dst_r, true);
}
imagecopyresampled($dst_r, $src_r, 0, 0, $delta_largeur, $delta_hauteur, $nouvelle_largeur, $nouvelle_hauteur, $this->get_largeur() - 2 * $delta_largeur, $this->get_hauteur() - 2 * $delta_hauteur);
/* En cas d'image non transparente on reduit à une image avec palette (pb de taille) */
if (!$src_alpha) {
$tmp = ImageCreateTrueColor($nouvelle_largeur, $nouvelle_hauteur);
ImageCopyMerge($tmp, $dst_r, 0, 0, 0, 0, $nouvelle_largeur, $nouvelle_hauteur, 100);
ImageTrueColorToPalette($dst_r, false, 8192);
ImageColorMatch($tmp, $dst_r);
ImageDestroy($tmp);
}
$qualite = $reduite ? self::qualite_png_reduite : self::qualite_png;
$ret = imagepng($dst_r, $this->get_src(), $qualite);
// Mise à jour des nouvelles dimensions
$this->largeur = $nouvelle_largeur;
$this->hauteur = $nouvelle_hauteur;
imagedestroy($dst_r);
}
} elseif ($this->get_ext() == _UPLOAD_EXTENSION_GIF) {
$dst_r = ImageCreateTrueColor($nouvelle_largeur, $nouvelle_hauteur);
if ($dst_r) {
imagecopyresampled($dst_r, $src_r, 0, 0, $delta_largeur, $delta_hauteur, $nouvelle_largeur, $nouvelle_hauteur, $this->get_largeur() - 2 * $delta_largeur, $this->get_hauteur() - 2 * $delta_hauteur);
$ret = imagegif($dst_r, $this->get_src());
// Mise à jour des nouvelles dimensions
$this->largeur = $nouvelle_largeur;
$this->hauteur = $nouvelle_hauteur;
imagedestroy($dst_r);
}
}
imagedestroy($src_r);
}
}
return $ret;
}
示例14: wtrmark
function wtrmark($sourcefile, $watermarkfile, $text)
{
$logopath = "/home/www/cb3/img/cb-logo-300.png";
$logofile_id = imagecreatefrompng($logopath);
imageAlphaBlending($logofile_id, true);
imageSaveAlpha($logofile_id, true);
$fileType = strtolower(substr($sourcefile, strlen($sourcefile) - 3));
switch ($fileType) {
case 'gif':
$sourcefile_id = imagecreatefromgif($sourcefile);
break;
case 'png':
$sourcefile_id = imagecreatefrompng($sourcefile);
break;
default:
$sourcefile_id = imagecreatefromjpeg($sourcefile);
}
imageAlphaBlending($sourcefile_id, true);
imageSaveAlpha($sourcefile_id, true);
//Get the sizes of both pix
$sourcefile_width = imageSX($sourcefile_id);
$sourcefile_height = imageSY($sourcefile_id);
$logo_width = imageSX($logofile_id);
$logo_height = imageSY($logofile_id);
$dest_x_logo = $sourcefile_width - $logo_width - 4;
$dest_y_logo = $sourcefile_height - $logo_height - 8;
// if a gif, we have to upsample it to a truecolor image
if ($fileType == 'gif') {
// create an empty truecolor container
$tempimage = imagecreatetruecolor($sourcefile_width, $sourcefile_height);
// copy the 8-bit gif into the truecolor image
imagecopy($tempimage, $sourcefile_id, 0, 0, 0, 0, $sourcefile_width, $sourcefile_height);
// copy the source_id int
$sourcefile_id = $tempimage;
}
// create an empty truecolor container
$tempimage = imagecreatetruecolor($sourcefile_width + 20, $sourcefile_height);
$bgColor = imagecolorallocate($tempimage, 255, 255, 255);
imagefill($tempimage, 0, 0, $bgColor);
// copy the 8-bit gif into the truecolor image
imagecopy($tempimage, $sourcefile_id, 0, 0, 0, 0, $sourcefile_width, $sourcefile_height);
// copy the source_id int
$sourcefile_id = $tempimage;
//text
$black = ImageColorAllocate($sourcefile_id, 200, 200, 200);
$white = ImageColorAllocate($sourcefile_id, 255, 255, 255);
//The canvas's (0,0) position is the upper left corner
//So this is how far down and to the right the text should start
$start_x = $sourcefile_width;
$start_y = $sourcefile_height;
// write text
Imagettftext($sourcefile_id, 10, 90, $sourcefile_width + 11, $sourcefile_height, $black, '/home/www/cb3/ales/arial.ttf', $text);
$opacity_logo = 30;
ImageCopyMerge($sourcefile_id, $logofile_id, $dest_x_logo, $dest_y_logo, 0, 0, $logo_width, $logo_height, $opacity_logo);
//Create a jpeg out of the modified picture
switch ($fileType) {
// remember we don't need gif any more, so we use only png or jpeg.
// See the upsaple code immediately above to see how we handle gifs
case 'png':
imagepng($sourcefile_id, $sourcefile);
break;
default:
imagejpeg($sourcefile_id, $sourcefile);
}
imagedestroy($sourcefile_id);
imagedestroy($logofile_id);
}
示例15: abs
if ($shadow) {
$box_width = abs($box[2] - $box[0]);
$box_height = abs($box[5] - $dip);
$shadow_image = @ImageCreate(abs($box[2] - $box[0]), abs($box[5] - $dip));
$shadow_background_color = @ImageColorAllocate($shadow_image, $background_rgb['red'], $background_rgb['green'], $background_rgb['blue']);
$shadow_color = ImageColorAllocate($shadow_image, 0, 0, 0);
$shadow_copy = ImageCopy($shadow_image, $image, 0, 0, 0, 0, $box_width, $box_height);
if ($kerning) {
kern_text($shadow_image, $font_size, 0, ceil($font_size * 0.05) - $box[0], abs($box[5] - $box[3]) - $box[1] + ceil($font_size * 0.05), $shadow_color, $font_file, $text, $kerning);
} else {
ImageTTFText($shadow_image, $font_size, 0, ceil($font_size * 0.05) - $box[0], abs($box[5] - $box[3]) - $box[1] + ceil($font_size * 0.05), $shadow_color, $font_file, $text);
}
if ($transparent_background) {
ImageColorTransparent($shadow_image, $shadow_background_color);
}
$shadow_merge = ImageCopyMerge($image, $shadow_image, 0, 0, 0, 0, $box_width, $box_height, 15);
ImageDestroy($shadow_image);
}
kern_text($image, $font_size, 0, -$box[0], abs($box[5] - $box[3]) - $box[1], $font_color, $font_file, $text, $kerning);
/*
ImageTTFText($image,$font_size,0,-$box[0],abs($box[5]-$box[3])-$box[1],
$font_color,$font_file,$text) ;
*/
// set transparency
if ($transparent_background) {
ImageColorTransparent($image, $background_color);
}
header('Content-type: ' . $mime_type);
ImagePNG($image);
// save copy of image for cache
if ($cache_images) {