Skip to content

bower support #26

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ The image object has the following properties:
- resized
- dataURL
- type
- width ( from jpeg exif )
- height ( from jpeg exif )
- name ( from jpeg exif )


### Multiple images with resizing

Expand All @@ -63,6 +67,9 @@ When used with multiple the image object is always an array of objects with the
- resized
- dataURL
- type
- width ( from jpeg exif )
- height ( from jpeg exif )
- name ( from jpeg exif )

See [demo.html](demo.html) for more concrete examples.

Expand Down Expand Up @@ -93,7 +100,8 @@ open http://localhost:8080

## Depends on

- angular-1.1.4
- angular-1.2.16
- angular-animate-1.2.16

## Tested in following browsers:

Expand Down
6 changes: 4 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angularjs-imageupload-directive",
"description": "imageupload Directive for AngularJS",
"version": "0.0.0",
"version": "0.0.2",
"main": "public/javascripts/imageupload.js",
"ignore": [
"**/.*",
Expand All @@ -10,6 +10,8 @@
"package.json"
],
"dependencies": {
"angularjs-unstable": "~1.1.4"
"angular": "1.2.16",
"angular-animate": "1.2.16",
"jsjpegmeta": "1.0.1"
}
}
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
{
"name": "angularjs-imageupload-directive",
"version": "0.0.1",
"version": "0.0.2",
"description": "Upload and resize images with AngularJS. Proof of Concept.",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/Mischi/angularjs-imageupload-directive.git"
"url": "https://github.com/Zacknero/angularjs-imageupload-directive.git"
},
"keywords": [
"AngularJS",
"Image",
"Upload",
"Resizing"
"Resizing",
"Exif"
],
"author": "Fabian Raetz",
"author": "Fabian Raetz","Zacknero"
"license": "BSD",
"dependencies": {
"express": "~3.1.0"
"angular": "1.2.16",
"angular-animate": "1.2.16",
"jsjpegmeta": "1.0.1"
}
}
36 changes: 33 additions & 3 deletions public/javascripts/imageupload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
angular.module('imageupload', [])

.directive('image', function($q) {
'use strict'

//require(["bower_components/jsjpegmeta/jpegmeta.js"],function(jpegmeta){});

var URL = window.URL || window.webkitURL;

var getResizeArea = function () {
Expand Down Expand Up @@ -72,6 +75,25 @@ angular.module('imageupload', [])
return deferred.promise;
};

var fileToDataInfo = function (file) {
var deferred = $q.defer();
var reader = new FileReader();
reader.onloadend = function(){

var exif = new JpegMeta.JpegFile(this.result, this.file.name);

deferred.resolve(exif);
};
reader.file = file;
reader.readAsBinaryString(file);


return deferred.promise;


};



return {
restrict: 'A',
Expand All @@ -80,7 +102,7 @@ angular.module('imageupload', [])
resizeMaxHeight: '@?',
resizeMaxWidth: '@?',
resizeQuality: '@?',
resizeType: '@?',
resizeType: '@?'
},
link: function postLink(scope, element, attrs, ctrl) {

Expand All @@ -89,15 +111,14 @@ angular.module('imageupload', [])
var dataURL = resizeImage(image, scope);
imageResult.resized = {
dataURL: dataURL,
type: dataURL.match(/:(.+\/.+);/)[1],
type: dataURL.match(/:(.+\/.+);/)[1]
};
callback(imageResult);
});
};

var applyScope = function(imageResult) {
scope.$apply(function() {
//console.log(imageResult);
if(attrs.multiple)
scope.image.push(imageResult);
else
Expand All @@ -123,6 +144,13 @@ angular.module('imageupload', [])
imageResult.dataURL = dataURL;
});

fileToDataInfo(files[i]).then(function(exif){
imageResult.name=exif.filename;
imageResult.width=exif.general.pixelWidth.value;
imageResult.height=exif.general.pixelHeight.value;

});

if(scope.resizeMaxHeight || scope.resizeMaxWidth) { //resize image
doResizing(imageResult, function(imageResult) {
applyScope(imageResult);
Expand All @@ -132,6 +160,8 @@ angular.module('imageupload', [])
applyScope(imageResult);
}
}


});
}
};
Expand Down