imagecopy
Description
Syntax
imagecopy( GdImage $dst_image, GdImage $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_width, int $src_height ): 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.
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; $return = imagecopy($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height); 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; imagecopy($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height); 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/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACSklEQVR4nO3b203rQBSF4cURz2jTwdAADA1AKkCpALkC5Aqs0EEqQFSAqAClAgMNICqwLBowD4lARAdjJ3vsPeP1KeIl+MLPxB7bABARERERERERERERERERERERERERERERERERERERhXAw9g7YIgLvMZsB2Hw9OsL5+eZdxoJzmM8xm+H0FCcnY++NTd5jucTbG5qm62tyRJDn/RpNMZZzuL/fpdG0Yu2faRKxRLBcKmRKP1aeo6rUSiUbyzk8PWlmSjZWlikPqGRj3d0FyZRaLBGUZcBS6cTyfsd55uRieR/qIJVarMFKRR9ryFJxxxq4VMSxRIY4oicSK/QsIZ1YQWeeScXKsnFKxRfLuaEP6hHHCnEvIc1YNzdjlmqaeB6FrecKx8dj7sPhmBvvoyg0Sz0/o64BQOT7GWoinNP5HFUVigLOba+8KDqdN+KgMrEqS4j8uokut8MioDKs2kt9aT/bRmD/YVVVnUoBEGn7PFonojCsFoseW2y5QrBOZW61dURv1/LrsW7/+zBl2Xujq9X/V/UvwA+oxnuFP5j6+NDYFQCwHev6euw9+Ml0rPlcYSUdz4Nx05q1N02/Xi0HeLsj6+pKbVV53uObVYbz0B4e1EZWXfeYlL6/Rzh10H14s1p12ujjY9tKjFKZuG+9Xl7+uJD+bXplPdbFhX6s9edxsdhOJoIsQ13/vbjRO6VFgdvbgOt/fd3c/ANwedl1qWjulOo6O9tlKaNTh/X/zVhjNJZNRmPZvEYxeoC3eZ42OrJsYqwePgFPQc12eT8tMAAAAABJRU5ErkJggg=="> </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
- imagecopymerge
- imagecopymergegray
- 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