Working with existing images is also possible. Even working with multiple images at once.
use GD; MAIN: { ... # Use the existing image of my Head... $img = "../../img/gv_head_48.png"; $head = GD::Image->newFromPng($img, 1); # Allocate the same red color, for new image. $red2 = $head->colorAllocate(255,0,0); # Draw a frame on the image... $head->rectangle(5,5,42,42,$red2); # Create result temp... open($fh, '>', "bn_t.png"); print $fh $head->png(); close($fh); # Copy part of my head (including my red frame) onto my banner # $image->copy($sourceImage, $dstX, $dstY, # $srcX, $srcY, $width, $height); $banner->copy($head, 335, 13, 5, 5, 38, 38); # Create result 7... open($fh, '>', "bn_7.png"); print $fh $banner->png(); close($fh); }
Result temp:
Result 7: