imagecopy
Copy part of an image
Description
bool 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
)
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 Values
Returns true
on success or false
on failure.
Examples
Example #1 Cropping the PHP.net logo
<?php
// Create image instances
$src = imagecreatefromgif('php.gif');
$dest = imagecreatetruecolor(80, 40);
// Copy
imagecopy($dest, $src, 0, 0, 20, 13, 80, 40);
// Output and free from memory
header('Content-Type: image/gif');
imagegif($dest);
?>
The above example will output
something similar to: