Git Product home page Git Product logo

Comments (4)

sai2333 avatar sai2333 commented on August 16, 2024

目前也需要这个参数,请问你是怎么解决的?

from image-cropper.

shinchanZ avatar shinchanZ commented on August 16, 2024

你好,请问有办法获取吗

from image-cropper.

shinchanZ avatar shinchanZ commented on August 16, 2024

通过获取图片和裁剪框位置强行实现了,就是感觉不太优雅😀

getImg(getCallback) {
			let query = wx.createSelectorQuery().in(this);
			let resourceInfo = new Promise((resolve, reject) => {
				query.select('#resource').boundingClientRect(function(rect) {
					resolve(rect)
				}).exec();
			})
			let cutInfo = new Promise((resolve, reject) => {
				query.select('.content_middle_middle').boundingClientRect(function(rect) {
					resolve(rect)
				}).exec();
			})



			this._draw(() => {
				wx.canvasToTempFilePath({
					width: this.data.width * this.data.export_scale,
					height: Math.round(this.data.height * this.data.export_scale),
					destWidth: this.data.width * this.data.export_scale,
					destHeight: Math.round(this.data.height) * this.data.export_scale,
					fileType: 'png',
					quality: this.data.quality,
					canvasId: this.data.el,
					success: (temp) => {
						Promise.all([resourceInfo, cutInfo]).then(res => {
							getCallback({
								origin: {
									url: this.data.imgSrc,
									width: res[0].width.toFixed(1),
									height: res[0].height.toFixed(1)
								},
								target: {
									url: temp.tempFilePath,
									width: res[1].width.toFixed(1),
									height: res[1].height.toFixed(1),
									x: (res[1].left - res[0].left).toFixed(1),
									y: (res[1].top - res[0].top).toFixed(1)
								}
							});
						}).catch(err => {
							console.log(err)
						})

					}
				}, this)
			});
		}

from image-cropper.

w-j-f avatar w-j-f commented on August 16, 2024

卧槽,牛逼我这想了好久,一直在找他的返回裁剪框在图片上的相对位置,没往这边考虑过

from image-cropper.

Related Issues (20)

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.