note 84306 added to function.imagecopy

From: Date: Tue, 08 Jul 2008 18:40:13 +0000
Subject: note 84306 added to function.imagecopy
Groups: php.notes 
Request: Send a blank email to php-notes+get-141276@lists.php.net to get a copy of this message
Here is some simple code for resizing an uploaded image and inserting a watermark (from a 24-bit PNG) on the bottom right of it. In this case, the water mark was a diagnol band that said "SOLD" across it. The code that verifies the uploaded image is the correct type has been omitted: <?PHP //Load and resize the image $uploaded = imagecreatefromjpeg($_FILES['file']['tmp_name']); $image = imagecreatetruecolor(IMAGE_WIDTH, IMAGE_HEIGHT); imagecopyresampled($image, $uploaded, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, imagesx($uploaded), imagesy($uploaded)); imagealphablending($image,true); //allows us to apply a 24-bit watermark over $image //Load the sold watermark $sold_band = imagecreatefrompng('../images/sold_band.png'); imagealphablending($sold_band,true); //Apply watermark and save $image = image_overlap($image, $sold_band); imagecopy($image,$sold_band,IMAGE_WIDTH - SOLD_WIDTH,IMAGE_HEIGHT - SOLD_HEIGHT,0,0,SOLD_WIDTH,SOLD_HEIGHT); $success = imagejpeg($image,'../images/sold/'.$id.'.jpg',85); imagedestroy($image); imagedestroy($uploaded); imagedestroy($sold_band); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 76.101.16.184 ---- Manual Page -- http://www.php.net/manual/en/function.imagecopy.php Edit -- https://master.php.net/note/edit/84306 Del: integrated -- https://master.php.net/note/delete/84306/integrated Del: useless -- https://master.php.net/note/delete/84306/useless Del: bad code -- https://master.php.net/note/delete/84306/bad+code Del: spam -- https://master.php.net/note/delete/84306/spam Del: non-english -- https://master.php.net/note/delete/84306/non-english Del: in docs -- https://master.php.net/note/delete/84306/in+docs Del: other reasons-- https://master.php.net/note/delete/84306 Reject -- https://master.php.net/note/reject/84306 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141276) next »