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

Show full size image after a rotation #220

Open
stanleyxu2005 opened this issue Dec 2, 2022 · 11 comments
Open

Show full size image after a rotation #220

stanleyxu2005 opened this issue Dec 2, 2022 · 11 comments

Comments

@stanleyxu2005
Copy link

I'm facing the same issue here.

Just take this official demo as example
https://codesandbox.io/s/vue-advanced-cropper-preview-experimental-fixed-aspect-ratio-eo9ed?file=/src/App.vue

The image is width=540, height=841 (rectangle)
After the image is rotated, the visiable area becomes a square.

image
image

Is it possible to make the image to be shown as "contain" mode, so that it is still show the full image, just like this?
image

@Norserium
Copy link
Collaborator

Norserium commented Dec 2, 2022

@stanleyxu2005, that's how the default rotate algorithm works. It tries to preserve the original cropped area on rotate as much as it possible.

Let's try to make clear what you want to get. What if, for example, the image was already zoomed and you rotate it?

@stanleyxu2005
Copy link
Author

stanleyxu2005 commented Dec 3, 2022

Hi @Norserium. Thank you for the quick response.

I'd like still to see the full image after a rotation, like this
image

I can adjust the zooming to see full image by scrolling mouse wheel. But when I programmatically set the zoom out, it does not seem to work

rotateAndFixImageSize() { 
      this.$refs.cropper.rotate(90)
      this.$refs.cropper.zoom(0.5) // attempt to fix image size
}

@Norserium
Copy link
Collaborator

Norserium commented Dec 3, 2022

@stanleyxu2005, I got it. This behavior can be easily over-defined in the future major version, but currently it's pretty tough task. How important is this issue for you? By the way, what's version Vue do you use?

@stanleyxu2005
Copy link
Author

stanleyxu2005 commented Dec 4, 2022

I tried to fiddle with imageClass, foregroundClass etc., but no luck. So I guess tweak zoom might work. As it is a tough task confirmed by repo owner, then I have to wait. :D

BTW, I'm currently using Vue 2. But I dont see any challenges if I switch projects to Vue 3.

@Norserium
Copy link
Collaborator

BTW, I'm currently using Vue 2. But I dont see any challenges if I switch projects to Vue 3.

I'm just going to support only Vue 2.7 / Vue 3 in the future due to using of Composition API under the hood in the new major release.

@stanleyxu2005
Copy link
Author

stanleyxu2005 commented Dec 4, 2022

I managed to use the following code as a workaround.

rotateAndFixImageSize() { 
    this.$refs.cropper.rotate(90)
    setTimeout(() => {
        this.resetImageSize()
    }, 500)
}

resetImageSize() {
    this.$refs.cropper.zoom(0.001)
}

Looking forward to your next major version

@hanzhenfang
Copy link

What about this problem now?I face the same issue.

@Norserium
Copy link
Collaborator

@hanzhenfang, I assume you want to get something like this in react-advanced-cropper?

@hanzhenfang
Copy link

I did it from the other side, when I first load the Cropper component, I will record an object named "primitiveStencilRect". It is assigned on the "defaultSize" props callback first invoked.

image

image

then I will use it for every rotate event.

image

tips: pay attention to the "width" and "height" at different degrees.😄

@hanzhenfang
Copy link

Hope some help for somebody.

@hanzhenfang
Copy link

@Norserium Thanks you also for you reply~😊

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