}
    // Create the image
    $im = imagecreatetruecolor($width, $height);
    imagealphablending($im, false);
    // Create some colors
    $fontC = imagecolorallocate($im, $array_colorcode['red'], $array_colorcode['green'], $array_colorcode['blue']);
    $bgc = imagecolorallocatealpha($im, 255, 0, 255, 127);
    imagefilledrectangle($im, 0, 0, $width, $height, $bgc);
    imagealphablending($im, true);
    // Add the text
    list($fontX, $fontY) = ImageTTFCenter($im, $text, $font, $fontSize);
    imagettftext($im, $fontSize, 0, $fontX, $fontY, $fontC, $font, $text);
    // Using imagepng() results in clearer text compared with imagejpeg()
    imagealphablending($im, false);
    imagesavealpha($im, true);
    imagetrim($im, $bgc, $padding);
    imagecanvas($im, $outputSize, $bgc, $padding);
    imagepng($im, $fileName);
    imagedestroy($im);
}
// The PHP ICO Generator
require './php-ico-master/class-php-ico.php';
// フォーマット(ico or png)
$format = $_POST["format"];
// 出力先(file path)
if ($format == "ico") {
    $destination = $dirPath . '/' . $fa . '.ico';
} else {
    $destination = $fileName;
}
// ファビコンの作成(generate favicon using The PHP ICO Generator)
Пример #2
0
function createCustomPrdImage($elemArr)
{
    //get total height of the design
    $totalheight = 220;
    //initial offset
    $totalwidth = 250;
    //initial offset
    foreach ($elemArr as $elm) {
        $totalheight += $elm['imgheight'];
        $totalwidth += $elm['imgwidth'];
    }
    $img = imagecreatetruecolor($totalwidth, $totalheight);
    imagesavealpha($img, true);
    $color = imagecolorallocatealpha($img, 0, 0, 0, 127);
    imagefill($img, 0, 0, $color);
    //start constructing the image
    $offsetx = 30;
    $offsety = 30;
    foreach ($elemArr as $key => $elm) {
        $imgpath = strpos($elm['style'], 'hook') === false ? "../productImages/" . $elm['selectedImage'] : "../productImages/" . $elm['hookImg'];
        $imgpart = imagecreatefrompng($imgpath);
        // $orig_w = $elm["imgwidth"];
        // $orig_h = $elm["imgheight"];
        list($orig_w, $orig_h) = getimagesize($imgpath);
        $dst_x = $elm['leftPos'];
        $dst_y = $elm['topPos'];
        if ($dst_x < 0 && $key == 0) {
            $offsetx += abs($dst_x);
        }
        $dst_x += $offsetx;
        $dst_y += $offsety;
        imagealphablending($imgpart, false);
        imagecopyresampled($img, $imgpart, $dst_x, $dst_y, 0, 0, $orig_w, $orig_h, $orig_w, $orig_h);
        imagesavealpha($img, true);
    }
    imagetrim($img, $color, '33 25 33 25');
    $ow = imagesx($img);
    $oh = imagesy($img);
    $out_w = $ow * 2;
    $out = imagecreatetruecolor($out_w, $oh + 20);
    imagesavealpha($out, true);
    imagefill($out, 0, 0, $color);
    $curr_x = 0;
    $curr_y = 0;
    $imgcount = 0;
    while ($curr_x < $out_w) {
        $imgcount++;
        if ($imgcount > 2) {
            break;
        }
        imagealphablending($out, true);
        imagecopy($out, $img, $curr_x, $curr_y, 0, 0, $ow, $oh);
        imagesavealpha($out, true);
        $curr_x += $ow - 25;
        $curr_y = 15;
    }
    $font = '../fonts/arial.ttf';
    $size = 8;
    $bbox = imagettfbbox($size, 0, $font, 'ky');
    $x = $ow - 10;
    $y = $bbox[5] + 30;
    $text = 'FITOORI DESIGNS';
    shadow_text($out, $size, $x, $y, $font, $text);
    $fn = md5(microtime() . "new") . "_custom.png";
    $result;
    if (imagepng($out, "../productImages/" . $fn, 9)) {
        $result = $fn;
    } else {
        $result = "ERROR";
    }
    imagedestroy($img);
    imagedestroy($out);
    return $result;
}