admin管理员组文章数量:1402122
I'm trying to resize image before sending it to the server to a canvas in React using nodeca/pica library:
import pica from 'pica'
let resizedCanvas = <canvas height={500} width={500}/>
pica().resize(myImage, resizedCanvas, {
unsharpAmount: 80,
unsharpRadius: 0.6,
unsharpThreshold: 2
}).then(result => console.log(`resize done! ${result}`))
.catch(err => console.log(err))
but I'm getting the following error in the console:
TypeError: stages.shift is not a function or its return value is not iterable
at processStages (index.js:508)
at init.then (index.js:549)
I'm trying to resize image before sending it to the server to a canvas in React using nodeca/pica library:
import pica from 'pica'
let resizedCanvas = <canvas height={500} width={500}/>
pica().resize(myImage, resizedCanvas, {
unsharpAmount: 80,
unsharpRadius: 0.6,
unsharpThreshold: 2
}).then(result => console.log(`resize done! ${result}`))
.catch(err => console.log(err))
but I'm getting the following error in the console:
TypeError: stages.shift is not a function or its return value is not iterable
at processStages (index.js:508)
at init.then (index.js:549)
Share
Improve this question
asked Jul 6, 2018 at 19:34
zorrozorro
2,5553 gold badges13 silver badges14 bronze badges
1 Answer
Reset to default 7The problem was that I should not use JSX for building the canvas. The following solution worked great:
const resizedCanvas = document.createElement('canvas')
resizedCanvas.height = 500
resizedCanvas.width = 500
本文标签: javascriptHow to resize images clientside with nodecapica and ReactStack Overflow
版权声明:本文标题:javascript - How to resize images client-side with nodecapica and React? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744346117a2601770.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论