imagesy($img_src)) { $dest_w = $max_dim; $dest_h = imagesy($img_src) * $max_dim / imagesx($img_src); } else { $dest_w = imagesx($img_src) * $max_dim / imagesy($img_src); $dest_h = $max_dim; } if (isset($scale)) { $dest_w = $dest_w * $scale / 100; $dest_h = $dest_h * $scale / 100; } // Create the final output image $img_dest = imagecreatetruecolor($dest_w,$dest_h); // Generate the final image // first the background imagecopyresampled($img_dest, $img_bg, 0, 0, 0, 0, $dest_w, $dest_h, imagesx($img_bg), imagesy($img_bg)); // then the image // imagecopyresampled($img_dest, $img_src, 0, 0, 0, 0, // $dest_w - $offset, $dest_h - $offset, // imagesx($img_src), imagesy($img_src)); imagecopyresampled($img_dest, $img_src, $offset, $offset, 0, 0, $dest_w - ($offset*2), $dest_h - ($offset*2), imagesx($img_src), imagesy($img_src)); // apply a watermark if ($size == "F" && isset($wm)) { $color = imagecolorallocatealpha($img_dest, 255, 200, 100, 60); imagettftext($img_dest, 20, 0, 20, $dest_h - 40, $color, "fonts/BOOKOS.TTF", "(c) Matt Schrier 2004"); } else if ($size == "T" && isset($overlay)) { $color = imagecolorallocatealpha($img_dest, 255, 200, 100, 0); imagettftext($img_dest, 11, 0, 10, $dest_h - 20, $color, "fonts/BOOKOS.TTF", $overlay); } // Output the image imageJPEG($img_dest,$imgname_cache,80); imageJPEG($img_dest,"",80); imageDestroy($img_dest); imageDestroy($img_src); } else // we are using cache { readfile($imgname_cache); } ?>