Comments (10)
The same happend to my. I rotate the image but when crop not appear rotate. Sorry my english
from ngcropper.
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.
Thanks for your comment but how can convert canvas object to dataurl with the angular mudule.
from ngcropper.
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.
thanks I'll try and tell you.
from ngcropper.
+1. Same issue with rotate — ngCropper
just not rotates the image.
from ngcropper.
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.
+1
from ngcropper.
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.
@maurobilotti thanks your suggestion, but got the cropped image shifted down and out the boundary.
from ngcropper.
Related Issues (20)
- ngCropper doesn't work in Angular Modal HOT 3
- Not working with jQuery 2.2.0 HOT 3
- Error when not specifying 'build' option HOT 1
- ngCropper and angular 1.5 HOT 6
- Can not move the crop area horizontally
- Get main image not from input field HOT 2
- ngCropper on load new image -> not working HOT 1
- dragStart event preview
- Change aspectRatio on click
- Start cropper from img src
- maximize:true does not work all image resolutions
- How can trigger zoom event? HOT 4
- ngCropper error element.cropper is not a function HOT 1
- Not working with Angular 1.5.8 and jQuery 2.2.4 HOT 2
- Not Working with Angular js 1.6.1
- cannot upload new images again and again HOT 2
- Accessing get data method?
- Problem with EXIF Image Orientation
- Is there support for circular area selection when cropping HOT 1
- Please add license file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngcropper.