$t3->setMaskFontSize(14); $t3->setMaskFontColor("#1A6BE6"); $t3->setMaskTxtPct(20); $t3->setDstImg(dirname(__FILE__).'/'.'out.jpg'); $t3->setMaskOffsetX(83); $t3->setMaskOffsetY(111); $t3->setMaskWord($con3); $t3->createImg(100); // 第四个水印 // $uinfo = OpenSDK_Tencent_Weibo::call('user/info'); $t4 = new ThumbHandler(); $t4->setSrcImg(dirname(__FILE__).'/'.'out.jpg'); $t4->setMaskFont("upload/simkai.ttf"); $t4->setMaskFontSize(14); $t4->setMaskFontColor("#FF0000"); $t4->setMaskTxtPct(20); $t4->setDstImg(dirname(__FILE__).'/'.'out.jpg'); $t4->setMaskOffsetX(150-$w/2); $t4->setMaskOffsetY(308); $t4->setMaskWord($userinfo); $t4->createImg(100); } //发送图片微博 if(file_exists('out.jpg')){ if(isset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]) && isset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET])){ $result = OpenSDK_Tencent_Weibo::call('t/add_pic', array( 'content' => "{$con}",//这里读取内容
function watermark($pic_path, $options = array()) { $sys_config = jconf::get(); if (!$sys_config['watermark_enable']) { return false; } if (!is_image($pic_path)) { return false; } $ims = @getimagesize($pic_path); if (in_array($ims['mime'], array('image/gif'))) { return false; } $new_pic_path = $options['new_pic_path']; if ('' == $new_pic_path) { $new_pic_path = $pic_path; } $image_quality = (int) $options['image_thumb_quality']; if ($image_quality < 1 || $image_quality > 100) { $image_quality = 100; } require_once ROOT_PATH . 'include/ext/thumb.class.php'; $_thumb = new ThumbHandler(); $_thumb->setSrcImg($pic_path); $_thumb->setDstImg($new_pic_path); $_thumb->setImgCreateQuality($image_quality); $_thumb->setMaskPosition($sys_config['watermark_position']); $_thumb->setMaskFontColor($sys_config['watermark_contents_color']); $_thumb->setMaskFontSize(max((int) $sys_config['watermark_contents_size'], 12)); $watermark = $options['watermark']; if ('' == trim($watermark)) { $member_info = $options['member_info']; if (!$member_info) { $uid = (int) $options['uid']; $member_info = $uid > 0 ? jsg_member_info($uid) : array(); } $username = $member_info['username'] ? $member_info['username'] : MEMBER_NAME; $nickname = $member_info['nickname'] ? $member_info['nickname'] : MEMBER_NICKNAME; if ($sys_config['watermark_contents'] && is_array($sys_config['watermark_contents'])) { if (in_array('nickname', $sys_config['watermark_contents']) && in_array('url', $sys_config['watermark_contents'])) { $_thumb->setMaskOffsetY(40); $_thumb->setMaskWord($sys_config['site_url'] . "/" . $username); $_thumb->createImg(100); $_thumb->setMaskOffsetY(10); $options['watermark'] = '@' . $nickname; return $this->watermark($pic_path, $options); } else { if (in_array('nickname', $sys_config['watermark_contents'])) { $watermark = '@' . $nickname; } else { $watermark = $sys_config['site_url'] . "/" . $username; } } } else { $watermark = $sys_config['site_url'] . "/" . $username; } } if (is_file($watermark)) { $_thumb->setMaskImgPct(100); $_thumb->setMaskImg($watermark); } else { $mask_word = (string) $watermark; if ($sys_config['watermark_contents'] && in_array('nickname', $sys_config['watermark_contents']) && is_file(RELATIVE_ROOT_PATH . 'images/jsg.ttf')) { $_thumb->setMaskFont(RELATIVE_ROOT_PATH . 'images/jsg.ttf'); $mask_word = array_iconv($sys_config['charset'], 'utf-8', $mask_word); } elseif (preg_match('~[\\x7f-\\xff][\\x7f-\\xff]~', $mask_word)) { $mask_word = $sys_config['site_url']; } $_thumb->setMaskWord($mask_word); } return $_thumb->createImg(100); }
$t3->setDstImg(dirname(__FILE__) . '/' . 'out.jpg'); $t3->setMaskOffsetX($t->src_w - $w - 60); $t3->setMaskOffsetY($t->src_h - 300 - $key * ($h + 10)); $t3->setMaskWord($item); $t3->createImg(100); } // 第四个水印日起 $da = "2012-" . rand(2, 12) . "-" . rand(1, 28) . ""; $b = imagettfbbox(14, 0, "upload/fangzheng.ttf", $da); //文字宽度 $w = abs($b[2] - $b[0]); $t4 = new ThumbHandler(); $t4->setSrcImg(dirname(__FILE__) . '/' . 'out.jpg'); $t4->setMaskFont("upload/fangzheng.ttf"); $t4->setMaskFontSize(46); $t4->setMaskFontColor("#13dd51"); $t4->setMaskTxtPct(20); $t4->setDstImg(dirname(__FILE__) . '/' . 'out.jpg'); $t4->setMaskOffsetX(($t4->src_w - $w - 170) / 2); $t4->setMaskOffsetY($t4->src_h - 280); $t4->setMaskWord($da); $t4->createImg(100); } } //发送图片微博 if (file_exists('out.jpg')) { if (isset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]) && isset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET])) { $result = OpenSDK_Tencent_Weibo::call('t/add_pic', array('content' => $message, 'clientip' => '123.119.32.253'), 'POST', array('pic' => array('type' => 'image/jpg', 'name' => '0.jpg', 'data' => file_get_contents('out.jpg')))); // 如果不要加关注作者,把下面语句注译去掉 if ($_POST['gz']) { $friendadd = OpenSDK_Tencent_Weibo::call('friends/add', array('name' => CREATER), 'post');
$t2->setMaskFont("upload/simkai.ttf"); $t2->setMaskFontSize(14); $t2->setMaskFontColor("#000000"); $t2->setMaskTxtPct(20); // $t2->setDstImgBorder(10,"#dddddd"); $t2->setDstImg(dirname(__FILE__) . '/' . 'out.jpg'); $t2->setMaskOffsetX(62); $t2->setMaskOffsetY(210); $t2->setMaskWord("{$nowAge} {$thisMonth}"); $t2->createImg(100); // 死亡时分秒 $t3 = new ThumbHandler(); $t3->setSrcImg(dirname(__FILE__) . '/' . 'out.jpg'); $t3->setMaskFont("upload/simkai.ttf"); $t3->setMaskFontSize(14); $t3->setMaskFontColor("#000000"); $t3->setMaskTxtPct(20); // $t2->setDstImgBorder(10,"#dddddd"); $t3->setDstImg(dirname(__FILE__) . '/' . 'out.jpg'); $t3->setMaskOffsetX(98); $t3->setMaskOffsetY(180); $t3->setMaskWord("{$thisDay} 24 {$thisMoment} {$thisSecond}"); $t3->createImg(100); } //发送图片微博 if (file_exists('out.jpg')) { if (isset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]) && isset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET])) { $result = OpenSDK_Tencent_Weibo::call('t/add_pic', array('content' => "{$con}", 'clientip' => '123.119.32.253'), 'POST', array('pic' => array('type' => 'image/jpg', 'name' => '0.jpg', 'data' => file_get_contents('out.jpg')))); print_r($result); } }