I need one help.I am using 'ngFileUpload','ngImgCrop'
to upload and crop the image using Angular.js.First let me to explain my code below.
<div ng-class="{ 'myError': billdata.bannerimage.$touched && billdata.bannerimage.$invalid }">
<input type="file" class="filestyle" data-size="lg" name="bannerimage" id="bannerimage" ngf-select ng-model="file" name="file" ngf-pattern="'image/*'" accept="image/*" ngf-max-size="20MB" ngf-min-height="100" ngf-resize="{width: 100, height: 100}" custom-on-change="uploadFile" multiple>
</div>
<label for="bannerimage" accesskey="B" ><span class="required">*</span> View Image</label>
<div style="padding-bottom:10px;">
<img ng-src="{{myCroppedImage}}" border="0" name="bannerimage" style="width:70px; height:70px;" id="imgId">
</div>
<div class="help-block" ng-messages="billdata.bannerimage.$error" ng-if="billdata.bannerimage.$touched">
<p ng-message="maxSize" style="color:#F00;">File is too large</p>
<p ng-message="minHeight" style="color:#F00;">Minimum height should be 100</p>
</div>
<div class="cropArea">
<img-crop image="myImage" result-image="myCroppedImage"></img-crop>
</div>
$scope.uploadFile = function(event){
console.log('event',event.target.files);
var files = event.target.files;
for (var i = 0; i < files.length; i++) {
var file = files[i];
var reader = new FileReader();
reader.onload = $scope.imageIsLoaded;
reader.readAsDataURL(file);
}
};
$scope.imageIsLoaded = function(e){
$scope.$apply(function() {
//$scope.stepsModel.push(e.target.result);
$scope.myImage=e.target.result;
$scope.myCroppedImage=$scope.myImage;
});
Here i am setting min-height="100"
.If any image has height less than 100 it is displaying error message.Here i need if any image has min-height less than 100 then it will ask for re-size the image and set again the file field.I can not do this using Image crop.Please help me.
Upload.resize()
to resize the image if the height is less than 100. You can get the image dimensions withUpload.imageDimensions()
. – danial Dec 19 '15 at 16:19