Пример #1
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;
}
Пример #2
0
<?php

require "functions.php";
$repo = $_GET["repo"] or null;
$username = $_GET["username"] or null;
if ($repo === null or $username === null) {
    die("UH OH!");
}
$url = curl_init("http://github.com/api/v1/json/{$username}/{$repo}/commit/master");
curl_setopt($url, CURLOPT_HEADER, false);
curl_setopt($url, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($url);
curl_close($url);
$arr = json_decode($json, true);
$image = imagecreatetruecolor(240, 80);
$FILL_ALPHA = imagecolorallocatealpha($image, 0, 0, 0, 50);
$FILL = imagecolorallocatealpha($image, 255, 255, 255, 127);
$FILL_TEXT = imagecolorallocatealpha($image, 255, 255, 255, 0);
$FILL_TEXT_SHADOW = imagecolorallocatealpha($image, 0, 0, 0, 50);
header("content-type: image/png");
dither_fill($image, $FILL);
shadow_text($image, 1, 1, 4, $repo, $FILL_TEXT, $FILL_TEXT_SHADOW);
// show only the first six characters of the commit id
if ($_GET["graph"] == 1) {
    shadow_text($image, 8, 13, 2, "Master [" . substr($arr['commit']['id'], 0, 6) . "]", $FILL_TEXT, $FILL_TEXT_SHADOW);
}
shadow_text($image, 16, 24, 1, $arr['commit']['message'], $FILL_TEXT, $FILL_TEXT_SHADOW);
imagepng($image);
imagedestroy($image);
Пример #3
0
function bill_denominations($bill)
{
    global $pdf;
    $p = $bill->p;
    $font_size = 23;
    if ($bill->card) {
        $font_size = 18;
    }
    $pdf->SetFont('Helvetica', 'B', $font_size);
    $pl = 's';
    //plaural
    if ($bill->amount == 1) {
        $pl = '';
    }
    $disp = $bill->amount;
    if ($bill->amount == 'open') {
        $disp .= ' Bitcoin' . $pl;
        $disp = '____ Bitcoins';
        $main = $disp;
    } else {
        $main = $disp . ' Bitcoin' . $pl;
    }
    //top left
    shadow_text($bill, $bill->y + $p + 0.2, $main, $bill->color, $bill->shadow_c, $bill->shadow);
    if ($bill->amount == 'open') {
        return;
    }
    //bottom right
    $pdf->SetFont($font, 'B', 20);
    shadow_text($bill, $bill->y + $bill->h - $p - 0.18, $disp . ' BTC', $bill->color, $bill->shadow_c, $bill->shadow, 'R');
    //top right
    $pdf->SetFont($font, 'B', 16);
    shadow_text($bill, $bill->y + $p + 0.12, $disp, $bill->color, $bill->shadow_c, $bill->shadow / 2, 'R');
    //bottom left
    $pdf->SetFont($font, 'B', 16);
    shadow_text($bill, $bill->y + $bill->h - $p - 0.18, $disp, $bill->color, $bill->shadow_c, $bill->shadow * 0.75, 'L');
    $pdf->SetTextColor(0);
}