Oh great and wise ones of PHP, smile upon this code which I so humbly lay at your feet, and see fit that the bugs therein may be smitten with your coding might.
<?
/
Variables-
$logo_file = Which logo to use.
$logo_im = Logo pointer.
$bg_file = Which background to use.
$bg_im = Background pointer.
$logo_wide = The width of the actual logo size.
$logo_high = The height of the actual logo size.
$logo_scale = The scale of the logo.
$scaled_x = The x size of the logo after scaling.
$scaled_y = The y size of the logo after scaling.
$stamp_x = The X coordinate of the logo to stamp it at.
$stamp_y = The Y coordinate of the logo to stamp it at.
/
//Set the variables. Later on, these will be loaded dynamically out of the database.
$logo_file = "logo_1.png";
$bg_file = "back_1.png";
$logo_wide = 100;
$logo_high = 100;
$stamp_x = 25;
$stamp_y = 25;
$scale = 100;
//Try to load the background, give an error if it couldn't be opened.
$bg_im = ImageCreateFromPNG("$bg_file");
if (!$bg_im) echo "Could not open the background image.";
//Try to load the logo, give an error if it couldn't be opened.
$logo_im = ImageCreateFromPNG("$logo_file");
if (!$logo_im) echo "Could not open the logo.";
//A little math to find out how big to paste the image.
//First, we turn the scale into a percentage value.
$scale = $scale / 100;
//Next, we take the size of the image being copied, and we multiply both height and width by the percentage.
$scaled_x = $logo_wide $scale;
$scaled_y = $logo_high $scale;
//Do the copying.
//imagecopyresized(dst_im, src_im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH )
ImageCopyResized ($bg_im, $logo_im, $stamp_x, $stamp_y, 0, 0, $scaled_x, $scaled_y, $logo_wide, $logo_high);
if (!$im) echo "Could not copy image.";
//Give the header to the browser and send the image.
Header("Content-type: image/png");
ImagePng($bg_im);
//Clean up the created image.
ImageDestroy ($bg_im);
ImageDestroy ($logo_im);
?>
It generates a broken picture type graphic. I've looked over everything, but alas, to no avail. Suggestions? My phpinfo is here:
http://www.verlynia.com/phpinfo.php
I am forever indebted to you for your kind service.
Humbly,
Mr. Crookston