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

Canvas support #9

Closed
mbwhite opened this issue Feb 19, 2018 · 5 comments
Closed

Canvas support #9

mbwhite opened this issue Feb 19, 2018 · 5 comments

Comments

@mbwhite
Copy link

mbwhite commented Feb 19, 2018

I've been reviewing the code to check if it's possible to apply Croppr.is to a canvas.
Would this be possible?

I understand that the aim of Croppr is get the size selection and then crop later.

@jamesssooi
Copy link
Owner

Hi @mbwhite, do you mean drawing the Croppr UI on top of a canvas? Or do you mean using Croppr to crop an existing canvas context? If it's the latter, you can refer to this comment I've made in another thread.

@mbwhite
Copy link
Author

mbwhite commented Feb 20, 2018

@jamesssooi ... I've an existing canvas element and the wish is to display the Croppr UI on top that.
So the user can specify how they believe the canvas should be cropped. It will contain an image - but also other elements drawn hence using a canvas.

@jamesssooi
Copy link
Owner

jamesssooi commented Feb 24, 2018

If you inspect Croppr's DOM, you'd see that Croppr's elements (handles, boxes, etc) are simply laid on top of an element.

So in theory, with some modifications to Croppr you can make it overlay these elements on top of your <canvas> element instead. Have a look inside the createDOM() method where it creates the <img> element.

An alternative method is to simply create an <img> element with it's src from your canvas using the fromDataURL() method. Then let Croppr work on that img element natively.

@mbwhite
Copy link
Author

mbwhite commented Mar 4, 2018

@jamesssooi Thanks for the update - sorry I didn't respond earlier.
I've found the section of code you mention; will see what I can do.

Will close this issue.

@mbwhite mbwhite closed this as completed Mar 4, 2018
@signalpoint
Copy link

signalpoint commented Nov 29, 2023

This comment appears to have a solid example of drawing the Croppr selection onto a canvas element.

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