|
@@ -40,7 +40,7 @@ class Image
|
|
|
|
|
|
set_time_limit(0);
|
|
|
@ini_set('memory_limit', '256M');
|
|
|
- $this->target = imagecreatetruecolor(640, 1008);
|
|
|
+ $this->target = imagecreatetruecolor(750, 1210); //750 背景宽度
|
|
|
|
|
|
$white = imagecolorallocate($this->target, 255, 255, 255);
|
|
|
imagefill($this->target, 0, 0, $white);
|
|
@@ -48,7 +48,7 @@ class Image
|
|
|
if (!empty($bg)) {
|
|
|
$bgWidth = imagesx($bg);
|
|
|
$bgHeight = imagesy($bg);
|
|
|
- $ratio = 640 / $bgWidth;
|
|
|
+ $ratio = 750 / $bgWidth; // 750 背景宽度
|
|
|
$newWidth = imagesx($bg) * $ratio;
|
|
|
$newHeight = imagesy($bg) * $ratio;
|
|
|
|
|
@@ -79,10 +79,12 @@ class Image
|
|
|
}
|
|
|
}
|
|
|
} elseif ($d['type'] == 'nickname') {
|
|
|
- $this->mergeText($d, $member['nickname']);
|
|
|
+// $this->mergeText($d, $member['nickname']);
|
|
|
+ $this->mergeText($d, $d['content']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ header("Content-Type:image/png");
|
|
|
imagepng($this->target, $path . $file);
|
|
|
imagedestroy($this->target);
|
|
|
|
|
@@ -108,10 +110,15 @@ class Image
|
|
|
|
|
|
public function mergeText($data, $text)
|
|
|
{
|
|
|
- $font = ROOT_PATH . '/public/assets/fonts/SourceHanSansK-Regular.ttf';
|
|
|
+// $font = ROOT_PATH . 'public/assets/fonts/SourceHanSansK-Regular.ttf';
|
|
|
+ $font = ROOT_PATH . '/public/assets/fonts/fangzheng.ttf';
|
|
|
+
|
|
|
if (!isset($data['color'])) {
|
|
|
$data['color'] = '#000';
|
|
|
}
|
|
|
+
|
|
|
+// $text = mb_convert_encoding($text, "GB2312", "UTF-8");
|
|
|
+// $text = iconv('gb2312','utf-8',$text);//解决乱码问题
|
|
|
$colors = $this->hex2rgb($data['color']);
|
|
|
$color = imagecolorallocate($this->target, $colors['red'], $colors['green'], $colors['blue']);
|
|
|
imagettftext($this->target, $data['size'], 0, $data['left'], $data['top'] + $data['size'], $color, $font, $text);
|
|
@@ -127,14 +134,6 @@ class Image
|
|
|
if (!is_file($imgurl)) {
|
|
|
return '';
|
|
|
}
|
|
|
- } else {
|
|
|
- $domain = 'thirdwx.qlogo.cn';
|
|
|
- if (strpos($imgurl, $domain) !== false) {
|
|
|
- $ip = gethostbyname($domain);
|
|
|
- if ($ip) {
|
|
|
- $imgurl = str_replace($domain, $ip, $imgurl);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
@$content = file_get_contents($imgurl);
|
|
|
if ($content) {
|