Git Product home page Git Product logo

Comments (10)

eduardogdo avatar eduardogdo commented on August 16, 2024

The same happend to my. I rotate the image but when crop not appear rotate. Sorry my english

from ngcropper.

lenciel avatar lenciel commented on August 16, 2024

Same problem here. I read the code and it seems that the wrapper function Cropper.crop(file, data) do not handle rotate parameter in data. You should call getCanvasData using your proxy and then convert the canvas object you get to dataurl before uploading.

from ngcropper.

eduardogdo avatar eduardogdo commented on August 16, 2024

Thanks for your comment but how can convert canvas object to dataurl with the angular mudule.

from ngcropper.

lenciel avatar lenciel commented on August 16, 2024

The canvas object has the method called toDataUrl(), so you can write something like this:

$scope. dataUrl = $scope.cropper.first('getCroppedCanvas', {
    width:150, 
    height: 150}).toDataURL();

You can of course change the width/height there in my example code (150/150) as you wish.

from ngcropper.

eduardogdo avatar eduardogdo commented on August 16, 2024

thanks I'll try and tell you.

from ngcropper.

artuska avatar artuska commented on August 16, 2024

+1. Same issue with rotate — ngCropper just not rotates the image.

from ngcropper.

artuska avatar artuska commented on August 16, 2024

Is there any way to refresh the cropper or refresh the duplicated image cropper uses? (There are two images — original image, which is hidden with .cropper-hidden class and duplicated original image which is used by cropper.)

from ngcropper.

mattmeye avatar mattmeye commented on August 16, 2024

+1

from ngcropper.

maurobilotti avatar maurobilotti commented on August 16, 2024

This made the magic for me:

       this.crop = function (file, data) {
            var _decodeBlob = this.decode;
            return this.encode(file).then(_createImage).then(function (image) {
                var canvas = createCanvas(data);
                var context = canvas.getContext('2d');

                drawImage(context, image, canvas, data.rotate);

                var encoded = canvas.toDataURL(file.type);
                removeElement(canvas);

                return _decodeBlob(encoded);
            });
        };

        function drawImage(ctx, image, canvas ,degrees) {
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            ctx.save();
            ctx.translate(canvas.width / 2, canvas.height / 2);
            ctx.rotate(degrees * Math.PI / 180);
            ctx.drawImage(image, -image.width / 2, -image.width / 2);
            ctx.restore();
        }

from ngcropper.

josephlaw avatar josephlaw commented on August 16, 2024

@maurobilotti thanks your suggestion, but got the cropped image shifted down and out the boundary.

from ngcropper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.