Renlok Posted January 2, 2008 Share Posted January 2, 2008 I'm trying to make a script where you can recolour an image how you want by applying colours different sections of an image and each section of the image is broken apart into its own image. And im not very good at GD but i have this script <?php //coords $base_x = array(100); $base_y = array(100); $eyes_x = array(43, 20); $eyes_y = array(83, 81); $detail_x = array(20,24,28,39,34,39,48,44,57,56,95,91,98); $detail_y = array(70,60,67,64,58,51,47,41,41,32,125,141,163); //testing page //header ("Content-type: image/png"); $dogoverlay = imagecreatefrompng("images/misk-junk/dog-over.png"); $dogbase = imagecreatefrompng("images/misk-junk/dog-base.png"); $dogeyes = imagecreatefrompng("images/misk-junk/dog-eyes.png"); $dogdetails = imagecreatefrompng("images/misk-junk/dog-detail.png"); list($width, $height, $type, $attr) = getimagesize("images/misk-junk/dog-over.png"); $background = imagecreate($width, $height); //get random colours to test with $newcolour1 = imagecolorallocate($background, 56, 160, 156); $newcolour2 = imagecolorallocate($background, 253, 175, 4); $newcolour3 = imagecolorallocate($background, 50, 207, 70); $border = imagecolorallocate($background, 10, 10, 10); //recolour base $dogbase = imagefilltoborder($dogbase, $base_x[0], $base_y[0], $border, $newcolour1); //recolour eyes for($i = 0; $i<count($eyes_x); $i++){ $dogeyesar[] = imagefilltoborder($dogeyes, $eyes_x[$i], $eyes_y[$i], $border, $newcolour2); } //recolour details for($i = 0; $i<count($detail_x); $i++){ $dogdetailsar[] = imagefilltoborder($dogeyes, $detail_x[$i], $detail_y[$i], $border, $newcolour3); } //stick it all together! $background = imagecopymerge($background,$dogbase,0,0,0,0,$width,$height,100); for($i = 0; $i<count($dogeyesar); $i++){ $background = imagecopymerge($background,$dogeyesar[$i],0,0,0,0,$width,$height,100); } for($i = 0; $i<count($dogdetailsar); $i++){ $background = imagecopymerge($background,$dogdetailsar[$i],0,0,0,0,$width,$height,100); } $background = imagecopymerge($background,$dogoverlay,0,0,0,0,$width,$height,100); imagepng($dogbase,NULL,100); //clean up the image imagedestroy($dogbase); imagedestroy($dogoverlay); imagedestroy($dogeyes); imagedestroy($dogdetails); ?> The errors it comes back with are Warning: imagecopymerge(): supplied argument is not a valid Image resource in /home/welinkco/public_html/roeonline/test2.php on line 35 Warning: imagecopymerge(): supplied argument is not a valid Image resource in /home/welinkco/public_html/roeonline/test2.php on line 37 Warning: imagecopymerge(): supplied argument is not a valid Image resource in /home/welinkco/public_html/roeonline/test2.php on line 40 Warning: imagecopymerge(): supplied argument is not a valid Image resource in /home/welinkco/public_html/roeonline/test2.php on line 42 Warning: imagepng(): supplied argument is not a valid Image resource in /home/welinkco/public_html/roeonline/test2.php on line 43 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/welinkco/public_html/roeonline/test2.php on line 45 Thanks in advance for any help Quote Link to comment https://forums.phpfreaks.com/topic/84138-gd-problem/ Share on other sites More sharing options...
MadTechie Posted January 2, 2008 Share Posted January 2, 2008 not sure why your using an array from an image!? $dogeyesar[] = imagefilltoborder($dogeyes, $eyes_x[$i], $eyes_y[$i], $border, $newcolour2); infact imagefilltoborder returns a boolean, so it should be imagefilltoborder($dogeyes, $eyes_x[$i], $eyes_y[$i], $border, $newcolour2); same for $dogdetailsar[] Quote Link to comment https://forums.phpfreaks.com/topic/84138-gd-problem/#findComment-428390 Share on other sites More sharing options...
Barand Posted January 2, 2008 Share Posted January 2, 2008 It would appear that the dogbase image create failed. Quote Link to comment https://forums.phpfreaks.com/topic/84138-gd-problem/#findComment-428421 Share on other sites More sharing options...
Renlok Posted January 2, 2008 Author Share Posted January 2, 2008 not sure why your using an array from an image!? $dogeyesar[] = imagefilltoborder($dogeyes, $eyes_x[$i], $eyes_y[$i], $border, $newcolour2); infact imagefilltoborder returns a boolean, so it should be imagefilltoborder($dogeyes, $eyes_x[$i], $eyes_y[$i], $border, $newcolour2); same for $dogdetailsar[] Cos im a noob Well it does load all the images, but i check each of them by print each out. They dont load correctly though they just look like a black blob with random bits of white it. But ive still no idea how to fix the other errors. Or how much would it cost me topay someone to code this script Quote Link to comment https://forums.phpfreaks.com/topic/84138-gd-problem/#findComment-428535 Share on other sites More sharing options...
MadTechie Posted January 2, 2008 Share Posted January 2, 2008 if you can supplie the images you have used i'll have a play, see what i can do (but i don't have much free time) Quote Link to comment https://forums.phpfreaks.com/topic/84138-gd-problem/#findComment-428623 Share on other sites More sharing options...
Renlok Posted January 2, 2008 Author Share Posted January 2, 2008 oh thanks the images i use are: http://www.roeonline.co.uk/images/misk-junk/dog-base.png http://www.roeonline.co.uk/images/misk-junk/dog-detail.png http://www.roeonline.co.uk/images/misk-junk/dog-eyes.png http://www.roeonline.co.uk/images/misk-junk/dog-over.png Quote Link to comment https://forums.phpfreaks.com/topic/84138-gd-problem/#findComment-428685 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.