note 103394 deleted from function.imagecopymerge by danbrown

From: Date: Tue, 12 Apr 2011 13:37:49 +0000
Subject: note 103394 deleted from function.imagecopymerge by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178768@lists.php.net to get a copy of this message
Note Submitter: Angel Ibaez Hernandez ---- jpeg image to png with semi-transparent text over: ---------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <?php $h = 200; $w = 200; //load JPEG from file (jpeg to png conversion in the function too) $img1 = imagecreatefromjpeg( "cuadrados.jpg" ); $w =imagesx( $img1 ); $h = imagesy( $img1 ); //create new true color image $img2 = imagecreatetruecolor( $w, $h ); //copy image 1 to image 2, as background imagecopy( $img2, $img1, 0, 0, 0, 0, $w, $h ); //create new true color image $img3 = imagecreatetruecolor( $w, $h ); $black = imagecolorallocate( $img3, 0, 0, 0 ); //black color $blackM = imagecolorallocate( $img3, 0, 0, 1 );// black color modified (if you need use black color) imagefill( $img3, 0, 0, $blackM);//fill image3 background whith black modified imagecolortransparent( $img3, $blackM );//set black modified as transparent color ¡ transparent background ! imagettftext( $img3, 28, -35, 70, 100, $black, "browa.ttf", 'sobretexto' ); //write text whit black color imagecopymerge( $img2, $img3, 0, 0, 0, 0, $w, $h, 20 ); //merge image 3 whit image 2, alpha = 20 imagepng( $img2, "prueba2.jpg" ); //image2 save to file //destroy images imagedestroy( $img3 ); imagedestroy( $img2 ); imagedestroy( $img1 ); ?> <br> <br> <center><img src="prueba2.jpg"></center><!--show image--> </body> </html>

« previous php.notes (#178768) next »