Hello,
I would like to generate only one image composed of other images. Also I would like to scale these images before creating the big image... please help me!
Thanks
Maga
Images Composed Of Images
[man]imagecopyresampled[/man] can be used to copy (and resize) one image onto another one at any given points on the large image.
Hello
First of all, thanks for your reply... but my problem is I don't know how to generate ONE image (jpg) from various images.... I'm using imagecreatetruecolor (to create a containing image) and I have 12 images in an array from flash. If I do a table with html and the src images are variables in a php document I've got what I want (a table with 12 dinamic images), but when I tried to get an image from these, the problem begins.... imagejpeg doesn't construct the image...
In short, do you know how could I get (generate) a jpg (only one) from 12 little jpgs and her correspondent layout (inside a table with cellpading, etc, etc) Please, help me!!!!!
THANKS AGAIN!
Hello again,
I found this code:
<?php
// config --
$src = array ("http://www.google.com/images/logo_sm.gif", "http://sk2.php.net/images/php.gif");
$under = 0; // combine images underneath or not?
// -- end of config
$imgBuf = array ();
$maxW=0; $maxH=0;
foreach ($src as $link)
{
switch(substr ($link,strrpos ($link,".")+1))
{
case 'png':
$iTmp = imagecreatefrompng($link);
break;
case 'gif':
$iTmp = imagecreatefromgif($link);
break;
case 'jpeg':
case 'jpg':
$iTmp = imagecreatefromjpeg($link);
break;
}
if ($under)
{
$maxW=(imagesx($iTmp)>$maxW)?imagesx($iTmp):$maxW;
$maxH+=imagesy($iTmp);
}
else
{
$maxW+=imagesx($iTmp);
$maxH=(imagesy($iTmp)>$maxH)?imagesy($iTmp):$maxH;
}
array_push ($imgBuf,$iTmp);
}
$iOut = imagecreate ($maxW,$maxH) ;
$pos=0;
foreach ($imgBuf as $img)
{
if ($under)
imagecopy ($iOut,$img,0,$pos,0,0,imagesx($img),imagesy($img));
else
imagecopy ($iOut,$img,$pos,0,0,0,imagesx($img),imagesy($img));
$pos+= $under ? imagesy($img) : imagesx($img);
imagedestroy ($img);
}
imagegif($iOut);
?>
It's almost what I want to do... but how could I put the array images in one table???? If $under is 0 the images shows in horizontal mode and if $under is 1 in vertical mode... but I want a table composed by 3 or 4 rows and columns.... please help me!
Thanks!
i would first create one blank image at the desired size using [man]imagecreatetruecolor[/man] and then for each additional image, you turn that into a gd image using imagecreatefrom... and use [man]imagecopyresampled[/man] to resize and place the images onto the main palette you create.
as to how you place the others and determine the size of the collaged image is up to however you want it to come out when its all done.