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

camanjs returns maximum callstack error on cropping source #231

Open
mejuliver opened this issue Oct 18, 2018 · 0 comments
Open

camanjs returns maximum callstack error on cropping source #231

mejuliver opened this issue Oct 18, 2018 · 0 comments

Comments

@mejuliver
Copy link

So first, I'm using jquery. Upon input change, i then add source to canvas then after that upon crop button click, trigger the crop function. Please refer below codes

<input type="file" id="input-file">
<canvas id="canvas-raw"></canvas>

<script>
$(function(){
 $('input#fileinput').change(function(e){
        renderImage(e);
    });
   $('button#crop-btn').click(function(){
   // call crop function
   camanCropper();
   });

});
function renderImage(e) {
    var canvas = document.getElementById('canvas-raw');
    var ctx = canvas.getContext('2d');
    var img = new Image;
    img.src = URL.createObjectURL(e.target.files[0]);
    img.onload = function() {
        canvas.setAttribute('width',img.width);
        canvas.setAttribute('height',img.height);
        ctx.drawImage(img,
            canvas.width / 2 - img.width / 2,
            canvas.height / 2 - img.height / 2
        );
    }
}

function camanCropper(){
    Caman("#canvas-raw", function(){
      // width, height, x, y
      this.crop(144, 134, 0, 0); // uses dummy points for right now
      // Still have to call render!
      this.render();
    });

}
</script>

then it gives me this error

Uncaught RangeError: Maximum call stack size exceeded caman.full.min.js:115

any help, ideas please?

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

1 participant