【发布时间】:2018-07-20 20:09:24
【问题描述】:
当使用 node.js 的锐利图像调整库https://github.com/lovell/sharp 时,图像正在旋转。
我没有显示 .rotate() 的代码,那么为什么要旋转它,如何阻止它旋转?
我正在使用 AWS 提供的 serverless-image-resizing 示例:https://github.com/awslabs/serverless-image-resizing,如果缩略图不存在,它使用 lambda 动态调整图像大小
S3.getObject({Bucket: BUCKET, Key: originalKey}).promise()
.then(data => Sharp(data.Body)
.resize(width, height)
.toFormat('png')
.toBuffer()
)
.then(buffer => S3.putObject({
Body: buffer,
Bucket: BUCKET,
ContentType: 'image/png',
Key: key,
}).promise()
)
.then(() => callback(null, {
statusCode: '301',
headers: {'location': `${URL}/${key}`},
body: '',
})
)
.catch(err => callback(err))
原始大图:
调整大小的图像:注意它也已旋转:
【问题讨论】:
标签: node.js amazon-s3 aws-lambda image-resizing sharp