Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get the current zoom level #218

Open
Emaxoso opened this issue Nov 4, 2022 · 8 comments
Open

Can't get the current zoom level #218

Emaxoso opened this issue Nov 4, 2022 · 8 comments

Comments

@Emaxoso
Copy link

Emaxoso commented Nov 4, 2022

I don't know if this is a bug or a missing feature.
I am trying to get the current zoom of the cropper, since for security reasons I need to crop on the server side, I was trying to find the image scale size.

I'm using the next branch

@Norserium
Copy link
Collaborator

@Emaxoso, hello!

First of all, why do you need to get the current zoom? To get the selected area you need coordinates only, they represent that area.

const { coordinates } = this.$refs.cropper.getResult();

If you really need to get the current zoom, you should know that there is not concept of absolute zoom. There is the visibleArea property that represents the current visible area of an image.

@Emaxoso
Copy link
Author

Emaxoso commented Nov 5, 2022

First of all, why do you need to get the current zoom? To get the selected area you need coordinates only, they represent that area.

I use the zoom to resize the image. First I do the cropping with the coordinates then I use the zoom to enlarge the image.

I was able to track the zoom by extending the Cropper component.

export default defineComponent({
	extends: Cropper,
	emits: ['scale'],
	watch: {
		src() {
			this.scale = 1.0;
		},
		scale() {
			this.$emit("scale", Math.round(this.scale * 1000) / 1000);
		}
	},
	data: () => ({
		scale: 1.0
	}),
	methods: {
		onManipulateImage(event, params = {}) {
			if (event && event.scale) {
				this.scale = Math.max(1, this.scale + 1 - event.scale.factor);
			}
			Cropper.methods.onManipulateImage.call(this, event, params);
		},
	},
});

@Norserium
Copy link
Collaborator

Norserium commented Nov 5, 2022

First I do the cropping with the coordinates then I use the zoom to enlarge the image.

@Emaxoso, I still don't get why? Should the following cases give the different result size?
image
image

It's pretty strange, because the cropped part is the same in both cases.

@dala00
Copy link

dala00 commented Jan 31, 2023

I also want to get current zoom level.
Because zoom level is specified by other indicator UI on our app.
Or I want to 'specify' zoom level of cropper.

@Norserium
Copy link
Collaborator

@dala00, I assume you want to get something like this?

@dala00
Copy link

dala00 commented Jan 31, 2023

Oh, yes!

@Norserium
Copy link
Collaborator

@dala00, @Emaxoso is this issue still actual?

@dala00
Copy link

dala00 commented Apr 15, 2023

I changed library (needed for job then)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants