- 在windows10安装node-canvas包可以运行,为什么上传到了微信小程序云函数不能运行?
[图片] 系统window10,开发工具:微信开发工具1.03.2010240查阅了资料(https://developers.weixin.qq.com/community/develop/doc/000aac769acb38ccb657f2d795e400)后有条资料显示用linux安装依赖和部署,但现在似乎还没有linux对应的微信开发者工具,我想问问是用linux系统打开云函数所在的文件夹然后安装依赖,再回到windows系统上面上传吗?还是有更加方便的解决办法?
2020-11-03 - canvasToTempFilePath部分ios手机导出图片裁剪?
真机截图(正常): [图片] iphone 7中截图(图片发生了裁剪): [图片] 核心代码片段(具体见代码片段:https://developers.weixin.qq.com/s/fUJ4d3m17UxT): <view class="page"> <canvas type="2d" style="width:{{canvasWidth}}px;height:{{canvasHeight}}px;" id="myCanvas" class="myCanvas" ></canvas> <image src="{{imageSrc}}" mode="widthFix"></image> </view> const app = getApp() Page({ data: { imageSrc: "", canvasWidth: '', canvasHeight: '', imageSrc:"" }, onLoad: async function () { let imageSrc = './1.jpg'; let imageInfo = await this.getImageInfo(imageSrc); let r = 2.165914247136675; let canvasWidth = Math.abs(imageInfo.width / r); let canvasHeight = Math.abs(imageInfo.height / imageInfo.width*canvasWidth); this.setData({ canvasWidth, canvasHeight },async ()=>{ let { canvas, context } = await this.initCanvas('#myCanvas', 1); let img = await this.createImage(canvas, imageSrc); context.drawImage(img, 0, 0, imageInfo.width, imageInfo.height, 0, 0, canvasWidth, canvasHeight) let src = await wx.canvasToTempFilePath({ x: 0, y: 0, width:canvasWidth, height:canvasHeight, destWidth:canvasWidth, destHeight:canvasHeight, canvas, success:(res)=>{ this.setData({ imageSrc:res.tempFilePath }) } }) }) }, getImageInfo(src) { return new Promise(async (resolve, reject) => { wx.getImageInfo({ src, success: (result) => { resolve(result); }, fail: (e) => { reject(e); } }); }); }, initCanvas(selector, dpr) { return new Promise((resolve, reject) => { wx.createSelectorQuery() .select(selector) .fields({ node: !0, size: !0 }) .exec((res) => { let canvasWidth = res[0].width; let canvasHeight = res[0].height; let canvas = res[0].node; let context = canvas.getContext('2d'); canvas.width = canvasWidth * dpr; canvas.height = canvasHeight * dpr; context.scale(dpr, dpr); resolve({ context, canvas, canvasWidth, canvasHeight }); }); }); }, createImage(ctxNode, imageSrc) { return new Promise((resolve, reject) => { const img = ctxNode.createImage(); img.src = imageSrc; img.onload = () => { resolve(img); }; }); } }) drawImage这一步是正常的,就是canvasToTempFilePath的时候发生了裁剪
2022-02-14