php 两站图生成海报
时间: 2023-10-03 11:10:18 浏览: 93
生成带二维码的图片可以使用以下代码:
```php
$config = array(
'image' => array(
array(
'url' => 'qrcode/qrcode.png', //二维码资源
'stream' => 0,
'left' => 116,
'top' => -216,
'right' => 0,
'bottom' => 0,
'width' => 178,
'height' => 178,
'opacity' => 100
)
),
'background' => 'bg/bg1.jpg' //背景图
);
$filename = 'bg/' . time() . '.jpg';
echo createPoster($config, $filename);
```
缩小图片可以使用以下代码:
```php
public function thumbImage($filename, $newFileName, $n_w = 160, $n_h = 160)
{
list($width, $height) = getimagesize($filename);
//缩放比例
if ($width > $n_w) {
$new = imagecreatetruecolor($n_w, $n_h);
$img = imagecreatefromjpeg($filename);
//copy部分图像并调整
imagecopyresized($new, $img, 0, 0, 0, 0, $n_w, $n_h, $width, $height);
//图像输出新图片、另存为
imagejpeg($new, $newFileName);
imagedestroy($new);
imagedestroy($img);
return array('width' => $n_w, 'height' => $n_h);
} else {
return array('width' => $width, 'height' => $height);
}
}
```
生成海报可以使用以下代码:
```php
$bigType = 2;
if ($this->newImage) {
imagejpeg($bigImg, $this->newImage);
} else {
switch ($bigType) {
case 2: //jpg
header('Content-Type:image/jpg');
imagejpeg($bigImg);
break;
default:
# code...
break;
}
}
```
以上代码可以用于在PHP中生成带二维码的海报。
#### 引用[.reference_title]
- *1* [php生成海报](https://blog.csdn.net/Jifei5201314/article/details/122896661)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [PHP生成海报/PHP合并图片/PHP图片处理](https://blog.csdn.net/coolpan123/article/details/82221559)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文