angularjs komprimieren Bild vor dem hochladen

Ich bin Gebäude ein web site, die für mobile Geräte verwendet angular-file-upload.min.js für das hochladen von Bildern von einem mobilen Gerät aus Bild-Bibliothek.

html-code:

<div>
    <div class="rating-camera-icon">
        <input type="file" accept="image/*" name="file" ng-file-
         select="onFileSelect($files)">
    </div>
    <img ng-show="fileName" ng-src="server/{{fileName}}" width="40"
     style="margin-left:10px">
</div>

code:

$scope.onFileSelect = function($files) {
        for (var i = 0; i < $files.length; i++) {
            var file = $files[i];
            if (!file.type.match(/image.*/)) {
                //this file is not an image.
            };
            $scope.upload = $upload.upload({
                url: BASE_URL + 'upload.php',
                data: {myObj: $scope.myModelObj},
                file: file
            }).progress(function(evt) {
                    //console.log('percent: ' + parseInt(100.0 * evt.loaded /evt.total));
                    //$scope.fileProgress = evt.loaded /evt.total * 100.0;
                }).success(function(data, status, headers, config) {
                    //file is uploaded successfully
                    $scope.fileName = data;
                });
        }
    };

Der upload ist sehr langsam in mobilen Geräten. Wie kann ich die Datei komprimieren?

  • wenn Sie nicht mit der nativen app, die Sie nicht komprimieren einer Datei auch die meisten der Bilder wie jpg sind bereits komprimiert, soweit ich weiß, gibt es nichts, was Sie tun können.
  • Wenn Sie auf der Suche für die Bildbearbeitung vor dem hochladen das könnte helfen: stackoverflow.com/questions/2434458/...
InformationsquelleAutor ben ezra | 2014-04-23
Schreibe einen Kommentar