Esempio n. 1
0
    // 执行处理并返回处理后的二进制数据
    //转换失败
    if ($new_data === false) {
        exit_status('error', 'p1:' . $img->errmsg());
    }
    $size = $img->getImageAttr();
    //覆盖加入3张图片
    $logo_ten_year_img = file_get_contents('../res/images/logo_ten_year110.png');
    $logo_zfb_img = file_get_contents('../res/images/logo_zfb100.png');
    $text_bg_img = file_get_contents('../res/images/text_back350.png');
    //清空$img数据
    $img->clean();
    //设定要用于合成的三张图片(如果重叠,排在后面的图片会盖住排在前面的图片)
    $img->setData(array(array($new_data, 0, 0, 1, SAE_TOP_LEFT), array($logo_ten_year_img, -10, 10, 1, SAE_BOTTOM_RIGHT), array($logo_zfb_img, -10, -10, 1, SAE_TOP_RIGHT), array($text_bg_img, 0, -47, 1, SAE_TOP_LEFT)));
    //执行合成
    $img->composite($size[0], $size[1]);
    //输出图片
    $new_data = $img->exec('jpg');
    if ($new_data === false) {
        exit_status('error', 'p2:' . $img->errmsg());
    }
    $s = new SaeStorage();
    $result = $s->write('rank', $file_name, $new_data);
    if (!$result) {
        exit_status('fail', $result);
    }
    $url = $s->getUrl('rank', $file_name);
    exit_status('ok', $url);
} else {
    exit_status('fail', 'no file accept!');
}
Esempio n. 2
0
 public function saeimage()
 {
     //从网络上抓取要合成的多张图片
     $img1 = file_get_contents('http://ss2.sinaimg.cn/bmiddle/53b05ae9t73817f6bf751&690');
     $img2 = file_get_contents('http://timg.sjs.sinajs.cn/miniblog2style/images/common/logo.png');
     $img3 = file_get_contents('http://i1.sinaimg.cn/home/deco/2009/0330/logo_home.gif');
     //实例化SaeImage并取得最大一张图片的大小,稍后用于设定合成后图片的画布大小
     $img = new SaeImage($img1);
     $size = $img->getImageAttr();
     //清空$img数据
     $img->clean();
     //设定要用于合成的三张图片(如果重叠,排在后面的图片会盖住排在前面的图片)
     $img->setData(array(array($img1, 0, 0, 1, SAE_TOP_LEFT), array($img2, 0, 0, 0.5, SAE_BOTTOM_RIGHT), array($img3, 0, 0, 1, SAE_BOTTOM_LEFT)));
     //执行合成
     $img->composite($size[0], $size[1]);
     //输出图片
     $img->exec('jpg', true);
 }