<?php

    function img($name, $src1, $src2, $src3, $src4, $src5, $src6, $src7, $src8, $src9)
    {
        $dest = ImageCreatefromJPEG('temp/' . $name . '/img.jpg');
        $src = ImageCreatefromJPEG('temp/' . $name . '/' . $src9 . '.jpg');
        $src1 = ImageCreatefromJPEG('temp/' . $name . '/' . $src1 . '.jpg');
        $src2 = ImageCreatefromJPEG('temp/' . $name . '/' . $src2 . '.jpg');
        $src3 = ImageCreatefromJPEG('temp/' . $name . '/' . $src3 . '.jpg');
        $src4 = ImageCreatefromJPEG('temp/' . $name . '/' . $src4 . '.jpg');
        $src5 = ImageCreatefromJPEG('temp/' . $name . '/' . $src5 . '.jpg');
        $src6 = ImageCreatefromJPEG('temp/' . $name . '/' . $src6 . '.jpg');
        $src7 = ImageCreatefromJPEG('temp/' . $name . '/' . $src7 . '.jpg');
        $src8 = ImageCreatefromJPEG('temp/' . $name . '/' . $src8 . '.jpg');

        if (function_exists('imagecopyresampled'))
            $imagecopy = imagecopyresampled;
        else
            $imagecopy = imagecopyresized;

        $imagecopy($dest, $src1, 0, 0, 0, 0, 32, 40, 32, 40);
        $imagecopy($dest, $src2, 32, 0, 0, 0, 32, 40, 32, 40);
        $imagecopy($dest, $src3, 64, 0, 0, 0, 32, 40, 32, 40);
        $imagecopy($dest, $src4, 0, 40, 0, 0, 32, 40, 32, 40);
        $imagecopy($dest, $src5, 32, 40, 0, 0, 32, 40, 32, 40);
        $imagecopy($dest, $src6, 64, 40, 0, 0, 32, 40, 32, 40);
        $imagecopy($dest, $src7, 0, 80, 0, 0, 32, 40, 32, 40);
        $imagecopy($dest, $src8, 32, 80, 0, 0, 32, 40, 32, 40);
        $imagecopy($dest, $src, 64, 80, 0, 0, 32, 40, 32, 40);

        // вывод картинки и очистка памяти
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
        header('Cache-Control: no-store, no-cache, must-revalidate');
        header('Cache-Control: post-check=0, pre-check=0', false);
        header('Pragma: no-cache');
        header("Content-Type: image/JPEG");

        ImageJPEG($dest, '', '30');

        ImageDestroy($src);
        ImageDestroy($src1);
        ImageDestroy($src2);
        ImageDestroy($src3);
        ImageDestroy($src4);
        ImageDestroy($src5);
        ImageDestroy($src6);
        ImageDestroy($src7);
        ImageDestroy($src8);

        ImageDestroy($dest);
    }

$name = abs(intval($_GET['name']));
$src1 = abs(intval($_GET['1']));
$src2 = abs(intval($_GET['2']));
$src3 = abs(intval($_GET['3']));
$src4 = abs(intval($_GET['4']));
$src5 = abs(intval($_GET['5']));
$src6 = abs(intval($_GET['6']));
$src7 = abs(intval($_GET['7']));
$src8 = abs(intval($_GET['8']));
$src9 = abs(intval($_GET['9']));

img($name, $src1, $src2, $src3, $src4, $src5, $src6, $src7, $src8, $src9);

?>