Skip to content

Commit

Permalink
可設定壓縮品質
Browse files Browse the repository at this point in the history
png除外
  • Loading branch information
ChangYinShung committed May 3, 2017
1 parent e600206 commit 5cb9a2c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion directive/ngCropperTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
width: '=',
height: '=',
resultImg: '=',
imgType:'@?', //圖片類型 : png or jpeg
quility:'@?', //圖片品質:Range 0-1
imgUrl: '@?',
isDone: '=?',
ctrl: '=?'
Expand Down Expand Up @@ -43,6 +45,8 @@
vm.width;
vm.height;
vm.isDone;
vm.quility = angular.isNumber(vm.quility) ? vm.quility : 1; //品質
vm.imgType = vm.imgType ? 'image/jpeg' : 'image/' + vm.imgType;
vm.ctrl = vm;
//var parameters
var ratio = 0;//finalSize.width / finalSize.height;
Expand Down Expand Up @@ -166,7 +170,7 @@
var dataUrl = $scope.cropper.first('getCroppedCanvas', {
width: w,
height: h
}).toDataURL();
}).toDataURL(vm.imgType, vm.quility);
vm.resultImg = vm.ogImage = dataUrl;
vm.HasImg = true;
vm.ShowCancel = false;
Expand Down

0 comments on commit 5cb9a2c

Please sign in to comment.