It sounds to me like you are trying to create one large image that contains several smaller ones.
The process to do that should be fairly simple:
- Create a large empty GD Image that is big enough to contain all your smaller images. You might want to set the background colour at this point.
- Load each image in turn, and paste it into your big image at the correct location.
- Save the big image in your prefered file format.
Overall your code might look something like this: (Untested)
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/rig
+ht.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, unab
+le to write output $!";
binmode OUTIMAGE;
print OUTIMAGE $outImage->png;
close OUTIMAGE;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.