I am trying to combine all of the images on this page using PHP.

The source code of the page is just a div block surrounding 15 square images.

Is it possible for PHP to combine all of this images together into one so that they look like what they do right now?

Yes it is. You need GD though.
I am pretty sure that my web server has the GD, I just don't know how to use it to combine the pictures.
If it's only filled squares, you may want to look at this: http://ca.php.net/manual/en/function.imagefilledrectangle.php
This sounds rather familiar: http://www.cemetech.net/forum/viewtopic.php?p=156688#156688 Smile
Well, I was wondering whether to continue that one thread. Just now I need to combine multiple images into one which is different from the OP in the other thread.
The solution I presented in that thread produces a single large image made up of multiple coloured rectangles, which is what I think you're after.
I want to combine specific images that could have varying lengths. The post that you had in the other thread generated a bunch of randomly colored squares rather than specific ones that I have correlated with the alphabet.

This is for the picture cipher I was talking about earlier and the cipher will convert input text into picture form. I want to make the output (which will be 100 X 5 if the total characters typed in the cipher is 500 and 56 x 1 if the total characters typed in the cipher is 56) become one complete picture.

I guess the real question that I am asking is how could I change, for example, the picture in here into one full picture?
The basic outline to merge multiple images using PHP and GD would be:

1) imcreatetruecolor() of the total output size
2) Repeatedly imcreatefrompng() (or appropriate format), then imcopy() into the output image
3) Either output the final image with headers directly, or save to a file.
Thank you for the input everyone, but I finished my project just about 1 hour ago. I used a similar version of Kerm's suggestion.


    for ($j = 0; $j < $lines; $j++) {
        for ($i = 0; $i < $cpl; $i++) {
           # echo "Row: " . $j . " Letter: " . $i . " Value: " . $split[($j*$cpl)+$i] . "<br>";

            $src = @imagecreatefrompng("images/" . $split[($j*$cpl)+$i] . ".png");
            @imagecopy($dest, $src, $i * $size, $j*$size, 0, 0, $size, $size);

The reason for the two for loops is for rows and columns.

I'll be posting my project in the Your Projects section soon for feedback.
Yup, that's exactly what I was saying. Smile You omitted the line showing your creation of $dest, but I'm sure it's as I suggested. Well done.
how can i marge two image from this code?????
please help me.

merge image is here upload/merge.png.


    /*** the upload directory ***/
    $upload_dir= './uploads';

    /*** numver of files to upload ***/
    $num_uploads = 5;

    /*** maximum filesize allowed in bytes ***/
    $max_file_size  = 51200;
    /*** the maximum filesize from php.ini ***/
    $ini_max = str_replace('M', '', ini_get('upload_max_filesize'));
    $upload_max = $ini_max * 1024;

    /*** a message for users ***/
    $msg = 'Please select files for uploading';

    /*** an array to hold messages ***/
    $messages = array();

    /*** check if a file has been submitted ***/
        /** loop through the array of files ***/
        for($i=0; $i < count($_FILES['userfile']['tmp_name']);$i++)
            // check if there is a file in the array
                $messages[] = 'No file uploaded';
            /*** check if the file is less then the max php.ini size ***/
            elseif($_FILES['userfile']['size'][$i] > $upload_max)
                $messages[] = "File size exceeds $upload_max php.ini limit";
            // check the file is less than the maximum file size
            elseif($_FILES['userfile']['size'][$i] > $max_file_size)
                $messages[] = "File size exceeds $max_file_size limit";
                // copy the file to the specified dir
                    /*** give praise and thanks to the php gods ***/
                    $messages[] = $_FILES['userfile']['name'][$i].' uploaded';
                    /*** an error message ***/
                    $messages[] = 'Uploading '.$_FILES['userfile']['name'][$i].' Failed';
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <title>Multiple File Upload</title>

 <h3><?php echo $msg; ?></h3>
    if(sizeof($messages) != 0)
        foreach($messages as $err)
            echo $err.'<br />';
 <form enctype="multipart/form-data" action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="post">
 <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>" />
    $num = 0;
    while($num < $num_uploads)
        echo '<div><input name="userfile[]" type="file" /></div>';

 <input type="submit" value="Upload" />

You're asking a lot and letting us shoot in the dark. This code is for an upload script. So, I'm assuming you want to merge the merge.png image to the file uploaded. Creating a script to merge two images would be as simple as adapting the code above your post to suit your needs.

If you're not familiar with PHP I suggest you look at http://www.php.net and searching what each of the functions do in the code we have here above you. Explore other functions and come up with an idea. Feel free to post your result and we'll be more than happy to aide you. But, as it stands, we have little inclination to help you: you haven't contributed help to other peoples projects, we have no info about the types of things required (is it going to be gif, png, jpg, etc?) and among a myriad of other small things this is a new account. You'll have to work with us and learn as we help you. If your code breaks or doesn't work we - I - expect you to fix it and not run back here and tell us it doesn't work.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum