php - Merging multiple images creates broken image -


so i'm attempting create array of names, take image associated name, , merge them together. code below seems return broken image.

<?php header('content-type: image/png'); $startlink = file_get_contents("http://websiteforimage.com/1/img.png"); $start = imagecreatefromstring($startlink); $name = array("2", "3", "4", "5", "6"); foreach($name $value){     $link = "http://websiteforimage.com/" . $value . "/img.png";     $img = imagecreatefrompng($link);     $offset = imagesx($start) + imagesx($img);     imagecopymerge($start, $img, $offset, 0, 64, 64, 64, 64, 100); } imagepng($start);  ?> 

any clue on how can fixed?

my initial thoughts imagecopymerge() function. don't state how you're merging them i'm going assume it's left right?

in case, co-ordinates seem wrong

$start  - sure, that's first image $img    - yes, that's new image attach $offset - makes sense, that's new image going start on destination 0       - makes sense too, starting @ top 64      - makes no sense me saying want start 64 pixels in on new image 64      - makes no sense again want start 64 pixels down on source image 64      - assume source 64 pixels wide 64      - ...and 64 pixels high? 

so assuming did mean that, appears fine. other question regarding function itself. thought imagecopymerge work if the place wanted put source existed on destination. eg, if destation 100 pixels wide , 100pixels high , wanted put image @ 99pixels left , 99pixels top, there's 1 pixel play , doesn't magically increase dimensions of destination.

so taking account i'm pretty sure first image needs large enough in advance take on board other images otherwise won't appear if x,y co-ordinates larger dimensions of destination. don't quote me on though, it's food thought!

good luck.

oh, follow - might want check out guide? appears doing same thing http://diceattack.wordpress.com/2011/01/03/combining-multiple-images-using-php-and-gd/


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -