php - 将图像分成两部分并显示图像 PHP
问题描述
我希望将图像分成两部分并保存图像并返回图像 url。我已经编写了代码,但不幸的是它无法正常工作,如果您知道解决方案,请告诉我
$orig = site_url('/') . $_POST['BatImageUrl'];
$width = 2500;
$height = 300;
if( $_POST['partName'] == 'handle' ) {
$leftSide = imagecreatetruecolor($width/2, $height);
$handleimage = imagecreatefrompng("handle-image.png");
imagecopy($leftSide, $orig, 0, 0, 0, 0, $width/2, $height);
header('Content-Type: image/gif');
imagepng($leftSide, $handleimage);
imagedestroy($leftSide);
} else {
$rightSide = imagecreatetruecolor($width/2, $height);
$barrelimage = imagecreatefrompng("barrel-image.png");
imagecopy($rightSide, $orig, 0, 0, $width/2, 0, $width/2, $height);
header('Content-Type: image/gif');
imagepng($rightSide, $barrelimage);
imagedestroy($rightSide);
}
imagedestroy($orig);
解决方案
推荐阅读
- javascript - 如何使响应以不同的顺序显示?
- javascript - 如何从侧边实现球和正方形之间的碰撞检测?
- blazor - Blazor WebAssembly 项目实时更新不起作用
- yaml - 如何将默认工作流(github 操作)发布到 git hub 市场?
- java - 有没有办法将参数插入到 sql avg 查询中?
- flutter - 在什么情况下应该使用 listview 而不是 listview.builder?
- sql-server - SQL Server db_datareader 无法将表编写为脚本,缺少什么权限?
- node.js - mustache 可以多次渲染 html 的图片吗?
- c++ - C++Builder 中的 OnClick 事件签名问题
- java - 相邻元素的最小绝对差并计算总和