letting apart the humor (which incidentally make your post harder to understand for non native english speakers.. :), you never set $resize background to white! I didnt follow all your geometry calculus, but be aware the the default background for a GD image is black:
perl -MGD -e"$im = new GD::Image(100,100);open $fh,'>','out.jpg';binmo +de $f; print $fh $im->jpeg"
The above print a nice black image.
Simplfying the whole I think you can start from something like the following code, which does what you are looking for
use strict; use warnings; use GD; GD::Image->trueColor(1); # gray image 100x100 my $im_gray = new GD::Image(100,100); my $gray = $im_gray->colorAllocate(127,127,127); $im_gray->filledRectangle(0, 0, 100,100, $gray); open my $fh_gray,'>','gray.jpg'; binmode $fh_gray; print $fh_gray $im_gray->jpeg; # red image 100x100 my $im_red = new GD::Image(100,100); my $red = $im_red->colorAllocate(255,0,0); my $black = $im_red->colorAllocate(0,0,0); $im_red->filledRectangle(0, 0, 100,100, $red); # with a black circle $im_red->ellipse(50,50,100,100,$black); open my $fh_red,'>','red.jpg'; binmode $fh_red; print $fh_red $im_red->jpeg; # copy resized red image scaled 50% and centered inside the gray one $im_gray->copyResized($im_red,25,25,0,0,50,50,100,100); open my $fh_both,'>','both.jpg'; binmode $fh_both; print $fh_both $im_gray->jpeg;
L*
In reply to Re^3: GD colorAllocate not changing colour -- working example
by Discipulus
in thread GD colorAllocate not changing colour
by Bod
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |