The key is the code starting from ob_end_clean();.
$backgroundPath = 'background_image_path'; $overlayPath = 'overlay_image_path';
$background = imagecreatefrompng($backgroundPath); $overlay = imagecreatefrompng($overlayPath);
$overlayWidth = imagesx($overlay); $overlayHeight = imagesy($overlay);
imagecopy($background, $overlay, 0, 0, 0, 0, $overlayWidth, $overlayHeight);
$output = imagecreatetruecolor($overlayWidth, $overlayHeight);
imagecopy($output, $background, 0, 0, 0, 0, $overlayWidth, $overlayHeight);
ob_end_clean(); header("content-type:image/png"); ob_start(); imagejpeg($output); $content = ob_get_contents(); ob_end_clean(); echo $content; die;
|