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

crop multiple images #164

Open
hoobig opened this issue Nov 2, 2016 · 1 comment
Open

crop multiple images #164

hoobig opened this issue Nov 2, 2016 · 1 comment

Comments

@hoobig
Copy link

hoobig commented Nov 2, 2016

1.html

<div class="form-group">
<input class="form-control animate-show" type="file" id="mainImage" name="mainImage" onchange="angular.element(this).scope().setFiles(this)" multiple>
<div class="cropArea animate-show img-responsive" ng-show="myImage" ng-repeat="image in myImage">
<img-crop id="myImage" area-min-size="100" image="image" result-image="files[$index]" result-image-format="image/jpeg" result-image-size="200">
</div>
<div ng-show="files" class="animate-show">Cropped
Image:</div>
<div ng-show="files" class="animate-show">
<img ng-repeat="file in files" ng-src="{{file}}" style="max-height:100px;" />
</div>

2.angular
$scope.setFiles = function (evt) {
$scope.myImage = [];
angular.forEach(evt.files, function (item) {
var file=item;
var reader = new FileReader();
reader.onload = function (evti) {
$scope.$apply(function($scope){
$scope.myImage.push(evti.target.result);
$scope.files.push(evti.target.result);
});
};
reader.readAsDataURL(file);
});
};

@hoobig
Copy link
Author

hoobig commented Nov 30, 2016

It's working for me and i share for you.

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