Exemplo n.º 1
0
}
if ($stage >= $jump) {
    // 做各小圖
    showmem("after free STB");
    for ($i = 0; $i < $total; $i++) {
        // im_file_gray($simage[$i], $simage[$i], $version);
        // 如果只有一張的情況
        if ($total == 1) {
            im_simage_resize($type, $simage[$i], $simage[$i], 'Center');
            break;
        }
        cli_msglog(sprintf("%d / %d", $i + 1, $total));
        im_simage_resize($type, $simage[$i], $simage[$i]);
        cli_msglog("resize small image...");
        $idxfile = sprintf("%s/index-%d.png", $outpath, $i);
        $idximg = imageindex($outx, $outy, $i, 80, 80);
        imagepng($idximg, $idxfile);
        cli_msglog("create index image...");
        $overlap = array('right' => 0, 'buttom' => 0);
        if (($i + 1) % $outx != 0) {
            $overlap['right'] = 1;
        }
        if ($i < $outx * ($outy - 1)) {
            $overlap['buttom'] = 1;
        }
        im_addborder($simage[$i], $simage[$i], $type, $overlap, $idxfile);
        unlink($idxfile);
        cli_msglog("small image border added ...");
        cli_msglog("ps:+" . sprintf("%d", 20 * $i + 1 / $total));
    }
}
Exemplo n.º 2
0
function addborder2($oim, $x, $y, $i, $imglib)
{
    // echo "calling addborder2( oim, newim, $x , $y, $i ) \n";
    // if (($i+1) % $x == 0)  $rightimg = "imgs/cut-r.png"; else $rightimg="imgs/paste-r.png";
    // if (($i+1) % $y == 0)  $buttonimg = "imgs/cut-b.png"; else $buttonimg="imgs/paste-b.png";
    if (($i + 1) % $x == 0) {
        $rightimg = $imglib[0];
    } else {
        $rightimg = $imglib[1];
    }
    if ($i >= $x * ($y - 1)) {
        $buttonimg = $imglib[2];
    } else {
        $buttonimg = $imglib[3];
    }
    $width = imagesX($oim);
    $height = imagesY($oim);
    // 因為支援 6x4 的關係, 變動加上的邊框大小
    list($rimx, $junk) = getimagesize($rightimg);
    list($junk, $bimy) = getimagesize($buttonimg);
    error_log("addcopypasteborder2 " . sprintf("original: %d x %d => new size: %d x %d\n", $width, $height, $width + $rimx, $height + $bimy));
    $newim = imageCreate($width + $rimx, $height + $bimy);
    $white = imageColorAllocate($newim, 0xff, 0xff, 0xff);
    $black = imageColorAllocate($newim, 0x0, 0x0, 0x0);
    // $im = ImageCreateFromPng($fname);
    $im = $oim;
    imageCopyMerge($newim, $im, 0, 0, 0, 0, imagesX($im), imagesY($im), 100);
    imageDestroy($im);
    $rim = imagecreatefrompng($rightimg);
    imageCopyMerge($newim, $rim, $width + 1, 0, 0, 0, imagesX($rim), imagesY($rim), 100);
    imageDestroy($rim);
    $bim = imagecreatefrompng($buttonimg);
    imageCopyMerge($newim, $bim, 0, $height + 1, 0, 0, imagesX($bim), imagesY($bim), 100);
    imageDestroy($bim);
    $idxim = imageindex($x, $y, $i, 95, 95);
    //imageCopyMerge($newim, $idxim, $width+2, $height+2, 0, 0, imagesX($idxim), imagesY($idxim), 100);
    imageCopyMerge($newim, $idxim, $width + $rimx - 98, $height + $bimy - 98, 0, 0, imagesX($idxim), imagesY($idxim), 100);
    imageDestroy($idxim);
    // imagePNG($newim,$newname);
    return $newim;
}