我正在使用 GraphicsMagic 来修改图像。在图像上绘制文本后,我需要将结果图像上传到 s3 存储桶。但是我怀疑 toBuffer() 返回空结果,因为我收到以下错误:
失败:预期 params.Body 为字符串、Buffer、Stream、Blob 或类型化数组对象
这是我的代码:
s3.getObject({Bucket: srcBucket, Key: srcKey}).promise()
.then(data => gm(data.Body)
.fill('white')
.stroke('black', 1)
.drawText(0, -60, text.toUpperCase(), 'center')
.toBuffer(imageType,function (err, buffer) {
if (err) return handle(err);
console.log('done!');
})
)
.then(buffer => s3.putObject({
Body: buffer,
Bucket: dstBucket,
ContentType: buffer.ContentType,
Key: dstKey,
}).promise()
)
.then(() => callback(null, {
statusCode: 200,
body: JSON.stringify({
url: dstKey
})
})
)
.catch(err => callback(err))
Run Code Online (Sandbox Code Playgroud) 我正在尝试用表情符号保存文本。然而,表情符号并不存储在文本中。我进入数据库而不是表情符号?。
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: utf8mb4
Run Code Online (Sandbox Code Playgroud)
下课后我想在哪里保存表情符号
/**
* Post
*
* @ORM\Table(name="post", options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"})
* @ORM\Entity(repositoryClass="AppBundle\Repository\PostRepository")
*/
class Post
{
/**
* @ORM\Column(type="integer", name="id")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="text", nullable=false, name="text")
*/
private $text;
}
Run Code Online (Sandbox Code Playgroud)
例子
发布正文
{"text": "test test"}
Run Code Online (Sandbox Code Playgroud)
text数据库中的列
test ? test
Run Code Online (Sandbox Code Playgroud) 我正在尝试从路径获取动画 gif 图像。但是我得到的不是动画的 gif
$im = imagecreatefromgif($path);
$newFilePath = app()->basePath("public/memes/") . $newname .'.gif';
header('Content-Type: image/gif');
imagegif($im, $newFilePath);
imagedestroy( $im );
return $newFilePath;
Run Code Online (Sandbox Code Playgroud)