imagecopymergegray
Description
The imagecopymergegray of Image for PHP copy and merge part of an image with gray scale.
Syntax
imagecopymergegray( GdImage $dst_image, GdImage $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_width, int $src_height, int $pct ): bool
Parameters
dst_image
Destination image resource.
src_image
Source image resource.
dst_x
x-coordinate of destination point.
dst_y
y-coordinate of destination point.
src_x
x-coordinate of source point.
src_y
y-coordinate of source point.
src_width
Source width.
src_height
Source height.
pct
The src_image will be changed to grayscale according to pct where 0 is fully grayscale and 100 is unchanged. When pct = 100 this function behaves identically to imagecopy() for pallete images, except for ignoring alpha components, while it implements alpha transparency for true colour images.
Return
Returns true on success or false on failure.
Examples
1 · return
<? $width = 100; $height = 100; $dst_image = imagecreatetruecolor($width, $height); $src_image = imagecreatetruecolor($width, $height); $dst_x = 0; $dst_y = 0; $src_x = 0; $src_y = 0; $src_width = $width; $src_height = $height; $pct = 50; $return = imagecopymergegray($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height, $pct); var_export($return); ?>
true
2 · base64
<? $width = 100; $height = 100; $dst_image = imagecreatetruecolor($width, $height); $filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/png/Happy.png'; $src_image = imagecreatefrompng($filename); $dst_x = 50; $dst_y = 50; $src_x = 0; $src_y = 0; $src_width = $width; $src_height = $height; $pct = 50; imagecopymergegray($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height, $pct); ob_start(); imagepng($dst_image); $output = ob_get_clean(); echo '<!doctype html> <html> <body> <img src="data:image/png;base64,' . base64_encode($output) . '"> </body> </html>'; ?>
<!doctype html> <html> <body> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABVElEQVR4nO3a0W6DMAxG4X9T3xvtzXcRqULaSHHrxHZyvktAFB2ZtoJIAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAhf0Rfwv+M4gj75p7PvMe0qEusFOts51t1GTxvGMjd62irW+5maTWJ9mqlZPpZPpubb8Vz5eJbSupPlnKlZcrKGlNKKsUaV0lq34cBMzTKTNbyUVok1o5SWiDWplOrHmldKxWNNLaXKsWaXUuVYAYrGChgr1YwVU0oFY4WVUsFYkWrFihwrlYoVXEqlYsWr8ojGfazOb7x5yXrp78KAtuV1shK3oeNYdZZQHN29UpFYXj5dbJI/ltdY3SzVOyx/rEQ2iWW6AS8PTh4r/o/oWfJYuRDLIHMsx3vQdKrLgzPHSmefWDeHq3fYPrEcpF0HP/DcF9tfj96GTx1aFB7RGLzzU8t3lgGxDIhlQCwDYhkQy4BYBr/zbxyPo5kESwAAAABJRU5ErkJggg=="> </body> </html>
Links
Related
Image
- gd_info
- getimagesize
- getimagesizefromstring
- image_type_to_extension
- image_type_to_mime_type
- imageaffine
- imageaffinematrixconcat
- imageaffinematrixget
- imagealphablending
- imageantialias
- imagearc
- imageavif
- imagebmp
- imagechar
- imagecharup
- imagecolorallocate
- imagecolorallocatealpha
- imagecolorat
- imagecolorclosest
- imagecolorclosestalpha
- imagecolorclosesthwb
- imagecolordeallocate
- imagecolorexact
- imagecolorexactalpha
- imagecolormatch
- imagecolorresolve
- imagecolorresolvealpha
- imagecolorset
- imagecolorsforindex
- imagecolorstotal
- imagecolortransparent
- imageconvolution
- imagecopy
- imagecopymerge
- imagecopyresampled
- imagecopyresized
- imagecreate
- imagecreatefromavif
- imagecreatefrombmp
- imagecreatefromgif
- imagecreatefromjpeg
- imagecreatefrompng
- imagecreatefromstring
- imagecreatefromtga
- imagecreatefromwbmp
- imagecreatefromwebp
- imagecreatefromxbm
- imagecreatefromxpm
- imagecreatetruecolor
- imagecrop
- imagecropauto
- imagedashedline
- imagedestroy
- imageellipse
- imagefill
- imagefilledarc
- imagefilledellipse
- imagefilledpolygon
- imagefilledrectangle
- imagefilltoborder
- imagefilter
- imageflip
- imagefontheight
- imagefontwidth
- imageftbbox
- imagefttext
- imagegammacorrect
- imagegetclip
- imagegetinterpolation
- imagegif
- imageinterlace
- imageistruecolor
- imagejpeg
- imagelayereffect
- imageline
- imageloadfont
- imageopenpolygon
- imagepalettecopy
- imagepalettetotruecolor
- imagepng
- imagepolygon
- imagerectangle
- imageresolution
- imagerotate
- imagesavealpha
- imagescale
- imagesetbrush
- imagesetclip
- imagesetinterpolation
- imagesetpixel
- imagesetstyle
- imagesetthickness
- imagesettile
- imagestring
- imagestringup
- imagesx
- imagesy
- imagetruecolortopalette
- imagettfbbox
- imagettftext
- imagetypes
- imagewbmp
- imagewebp
- imagexbm
- iptcembed
- iptcparse