GithubHelp home page GithubHelp logo

ifmiss / wx-cropper Goto Github PK

View Code? Open in Web Editor NEW
339.0 9.0 115.0 6.04 MB

:scissors: 微信小程序 图片裁剪工具,简单易用

License: MIT License

JavaScript 100.00%
weixin cropper wui wecropper wxcropper weixincropper we-cropper

wx-cropper's Issues

旋转的问题

我想添加旋转的功能,每次顺时针旋转90度,思路是用canvas画出图,然后用canvasContext.translate改变中点到图片中间,再用canvasContext.rotate旋转,最后用canvasToTempFilePath画图保存下来。
现在碰到问题在于canvasContext.translate和canvasContext.rotate这一步
无法正确设置到图片中点。。。

rotateImage() {
				var _this = this
				wx.downloadFile({
					url: _this.data.imageSrc, //仅为示例,并非真实的资源
					success: function (doloadRes) {
						wx.getImageInfo({
							src: _this.data.imageSrc,
							success: function success(res) {
								const ctx = wx.createCanvasContext('myCanvas')
								ctx.translate(res.width / 2, res.height / 2);
								ctx.rotate(90 * Math.PI / 180)
								ctx.drawImage(doloadRes.tempFilePath);
								ctx.draw(true, () => {
									console.log('res.height', res.height)
									console.log('res.width', res.width)
									_this.imageW = res.height;
									_this.imageH = res.width;
									wx.canvasToTempFilePath({
										x: 0,
										y: 0,
										width: res.height,
										height: res.width,
										canvasId: 'myCanvas',
										success: function (drawRes) {
											// 成功获得地址的地方
											console.log(drawRes.tempFilePath)
										}
									})
								})
							}
						})
					}
				})
			},

不知是否可以提供一些帮助?

CanvasToTempFilePath首次生成文件为空

第一次执行“生成图片”总是无法预览,debug发现首次生成文件为空。
将preview移到complete中可以解决这个问题:
wx.canvasToTempFilePath({
x: canvasL,
y: canvasT,
width: canvasW,
height: canvasH,
destWidth: canvasW,
destHeight: canvasH,
canvasId: 'myCanvas',
complete: function() {
wx.previewImage({
current: '', // 当前显示图片的http链接
urls: [res.tempFilePath] // 需要预览的图片http链接列表
})

      }
    })

mpvue

您好可以使用在mpvue中吗?

真机不行啊,是我太坑?

从电脑模拟器选择的图片路径是http开头的,所以点击生成图片的时候可以正常生成图片
从真机相册选择的图片路径是wxfile开头的,点击生成图片就死掉了,直接ctx.draw本地图片也是不行的.....

裁剪后的效果

您好 我使用你的库 发现长图 裁剪后是压缩的 而不是裁剪框的大小

微信小程序小白来提个问题

话说生成图片了,地址也打印出来了,但是怎么把图片存起来呢?或者怎么用那个图片的地址呢?我不能直接打开啊。是要在小程序里面才能打开那个地址吗?

v2 分支在某些 iOS 机型下(6s / 7 plus) 有裁剪出来只有一小部分的问题

期望行为

裁剪正常,和预览时的框框一致

实际行为

bug
bug2

如何复现

  • OnePlus 6T 无法复现
  • iPhoneX 无法复现

拿这俩测试纯粹是因为公司里只有这俩

问题机型

  • iPhone 6S
  • iPhone 7 Plus

这俩机型是用户告诉我们的

问题出现频率

偶尔出现,解决方法是关了小程序再开

用户的操作步骤

选择多张图片,选择不同的裁剪比例(裁剪框我控制成了无法放大缩小)
移动裁剪框。裁剪。

调试过程

安卓 OnePlus 6T 尝试类似步骤,无法复现。
iPhoneX 无法复现。
Testing 云测使用 iPhone 6S 无法复现
Testing 云测使用 iPhone 7 Plus 无法复现

问题

请问作者有没有思路这可能是什么问题,如何进一步定位。
或者只能是 ┑( ̄Д  ̄)┍ 了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.