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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

canvas.toDataURL doesn't respect stencil #23

Closed
andreasvirkus opened this issue Dec 3, 2019 · 5 comments
Closed

canvas.toDataURL doesn't respect stencil #23

andreasvirkus opened this issue Dec 3, 2019 · 5 comments

Comments

@andreasvirkus
Copy link

Hi, thanks for an awesome component! The docs are great and the component is very easy to use 馃挴

I have an issue with calling

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

this.$emit("submit", canvas.toDataURL())

with both the default CircleStencil and the advanced stencil example. The result is always a rectangle with full corners.

I've also created a replication here:

https://codesandbox.io/s/vue-sc4k6

croppa-small

My current workaround is to apply a small border radius to the image that displays the result, but ideally (especially with maybe changing the stencil in the future), I'd like a way to get the image cropped by the stencil 馃檹

@Norserium
Copy link
Collaborator

Norserium commented Dec 3, 2019

Hello, @andreasvirkus!

First of all, thanks for so detailed the issue description.

Unfortunately, it's not possible by the means of this library, because the stencil just defines the rectangle area that will be cropped. Moreover, it's pretty often practice to crop a square by the circle stencil.

But you can anyway process a rectangle canvas to get the needed result (if you want to use this method, test it on different browsers before to use one in production):
https://codesandbox.io/s/vue-xeb59

@andreasvirkus
Copy link
Author

Well, that seems to work perfectly! 馃帀 Thank you so much, my canvas-fu was too weak for this

@Norserium
Copy link
Collaborator

You are welcome!

@yellow1912
Copy link

yellow1912 commented Feb 10, 2022

This is great content, please add it to the document if you can. It will save people like me tons of time digging the old issues.

@Norserium
Copy link
Collaborator

Norserium commented Feb 10, 2022

@yellow1912 , I will try to think out how to place it in the documentation, taking into account that the mentioned issues are still edge cases.

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