note 85517 added to function.imagecopymerge

From: Date: Wed, 03 Sep 2008 13:01:28 +0000
Subject: note 85517 added to function.imagecopymerge
Groups: php.notes 
Request: Send a blank email to php-notes+get-144113@lists.php.net to get a copy of this message
Some highly amusing stuff: This code appears normal and is a way to cut out slices of an image randomly. <?php header("Content-Type: image/jpeg"); $width=837; $height=771; $origim = imagecreatefromjpeg("theimage.jpeg"); /* Attempt to open */ $imagetodisplay=imagecreate($width, $height); for($i=0;$i<=100;$i++) { $xPos=rand(0,$width-9); $yPos=rand(0,$height-9); imagecopy($imagetodisplay, $origim, $xPos, $yPos , $xPos, $yPos , 10 , 10); } imagejpeg($imagetodisplay); imagedestroy($imagetodisplay); imagedestroy($origim); ?> Try running this however and an omitted detail adds to the fun. Since the first colour that is defined is taken to be the background colour, we have a random colour selected from $origim as the background colour for $imagetodisplay, but this random colour is weighted according to the background image. It was a surprise (I thought the bg would be black) but I am now keeping it as it looks good. ---- Server IP: 92.48.74.199 Probable Submitter: 90.204.167.212 ---- Manual Page -- http://www.php.net/manual/en/function.imagecopymerge.php Edit -- https://master.php.net/note/edit/85517 Del: integrated -- https://master.php.net/note/delete/85517/integrated Del: useless -- https://master.php.net/note/delete/85517/useless Del: bad code -- https://master.php.net/note/delete/85517/bad+code Del: spam -- https://master.php.net/note/delete/85517/spam Del: non-english -- https://master.php.net/note/delete/85517/non-english Del: in docs -- https://master.php.net/note/delete/85517/in+docs Del: other reasons-- https://master.php.net/note/delete/85517 Reject -- https://master.php.net/note/reject/85517 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#144113) next »