Copy part of an image in PHP

Description

The following code shows how to copy part of an image.

Example


<?php/*w w w .j  av  a 2 s. c  om*/
// Create image instances
$src = imagecreatefromgif('./test.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);

imagedestroy($dest);
imagedestroy($src);
?>

The code above generates the following result.

Copy part of an image in PHP




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text