use strict; use warnings; use GD; my $outImage = GD::Image->new(1000,1000); # Assume this image is 500x500 pixels my $imageTopLeft = GD::Image->newFromPng('/path/to/file/top/left.png'); $outImage->copyResized($imageTopLeft, # Src Image; 0,0, # $dstX,$dstY, 0,0, # $srcX,$srcY, 500, 500, # $destW,$destH, 500, 500 ); # $srcW,$srcH, # Assume this image is 200x300 pixels my $imageBottomRight = GD::Image->newFromPng('/path/to/file/bottom/right.png'); $outImage->copyResized($imageBottomRight, # Src Image; 800,700, # $dstX,$dstY, 0,0, # $srcX,$srcY, 200, 300, # $destW,$destH, 200, 300 ); # $srcW,$srcH, open OUTIMAGE, ">", '/path/to/output/filename.png' or die "Error, unable to write output $!"; binmode OUTIMAGE; print OUTIMAGE $outImage->png; close OUTIMAGE;