我按照Firecasts的Firebase函数教程(https://www.youtube.com/watch?v=pDLpEn3PbmE&t=338s)使用Firebase上传图片并创建缩略图,一切都很顺利。但是,当我上传用iPhone拍摄的照片时,它会被旋转(竖直照片保存为水平照片)。因此,我进行了一些研究,并发现了ImageMagick的
但是当我把它部署到Firebase上并尝试上传图片时,我收到了以下错误消息,它没有给我关于为什么不起作用的很多信息:
“函数执行花费了6227毫秒,完成状态为:'连接错误'”
有任何想法吗?
-auto-orient
参数(http://magick.imagemagick.org/script/command-line-options.php#auto-orient)。但是,我不确定如何将此参数添加到spawn函数中以考虑此参数。以下是我的工作代码(仅涉及相关部分),不包括-auto-orient
。...
return bucket.file(filePath).download({
destination: tempFilePath
})
.then(() => {
console.log('Image downloaded locally to', tempFilePath);
return spawn('convert', [tempFilePath, '-thumbnail', '200x200>', tempFilePath]);
})
.then(() => {
console.log('Thumbnail created!');
const thumbFilePath = filePath.replace(/(\/)?([^\/]*)$/, '$1thumb_$2');
console.log(`thumbFilePath: ${thumbFilePath}`);
return bucket.upload(tempFilePath, {
destination: thumbFilePath
});
})
...
我尝试使用-auto-orient
参数的代码
...
return bucket.file(filePath).download({
destination: tempFilePath
})
.then(() => {
console.log('Image downloaded locally to', tempFilePath);
return spawn('convert', ['-auto-orient', tempFilePath, '-thumbnail', '200x200>', tempFilePath]);
})
.then(() => {
console.log('Thumbnail created!');
const thumbFilePath = filePath.replace(/(\/)?([^\/]*)$/, '$1thumb_$2');
console.log(`thumbFilePath: ${thumbFilePath}`);
return bucket.upload(tempFilePath, {
destination: thumbFilePath
});
})
...
但是当我把它部署到Firebase上并尝试上传图片时,我收到了以下错误消息,它没有给我关于为什么不起作用的很多信息:
“函数执行花费了6227毫秒,完成状态为:'连接错误'”
有任何想法吗?