{"action":"reopened","issue":{"url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/568","labels_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/568/labels{/name}","comments_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/568/comments","events_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/568/events","html_url":"https://github.com/danialfarid/ng-file-upload/issues/568","id":57782023,"number":568,"title":"How can I get the image size before uploading?","user":{"login":"burzum","id":162789,"avatar_url":"https://avatars.githubusercontent.com/u/162789?v=3","gravatar_id":"","url":"https://api.github.com/users/burzum","html_url":"https://github.com/burzum","followers_url":"https://api.github.com/users/burzum/followers","following_url":"https://api.github.com/users/burzum/following{/other_user}","gists_url":"https://api.github.com/users/burzum/gists{/gist_id}","starred_url":"https://api.github.com/users/burzum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/burzum/subscriptions","organizations_url":"https://api.github.com/users/burzum/orgs","repos_url":"https://api.github.com/users/burzum/repos","events_url":"https://api.github.com/users/burzum/events{/privacy}","received_events_url":"https://api.github.com/users/burzum/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-02-16T09:34:21Z","updated_at":"2015-12-10T04:02:57Z","closed_at":null,"body":"How can I get the image size before uploading? I need to get the size to validate that the image is at least X pixel width and height.\r\n\r\nI know I can do it like this in a directive that I apply to the `<img>` element itself.\r\n\r\n```js\r\n\t\tlink: function(scope, element, attributes) {\r\n\t\t\telement.on('load', function () {\r\n\t\t\t\tscope.cmsImageSize.originalHeight = this.height;\r\n\t\t\t\tscope.cmsImageSize.originalHidth = this.width;\r\n\t\t\t});\r\n\t\t}\r\n````\r\n\r\nBut how do I get it from within my files I'm watching? I've spent now some time inspecting the objects I have there but couldn't figure out from where I could get the image dimensions.\r\n\r\n```js\r\n$scope.$watch('data.files', function() {\r\n\t\t\t\tfor (var i = 0; i < $scope.data.files.length; i++) {\r\n\t\t\t\t\tvar file = $scope.data.files[i];\r\n\t\t\t\t\t$scope.upload = $upload.upload({\r\n\t\t\t\t\t\turl: '/api/v1/image_files/upload.json',\r\n\t\t\t\t\t\tmethod: 'POST',\r\n\t\t\t\t\t\tdata: {\r\n\t\t\t\t\t\t\t'data[ImageFile][model]': 'CmsPageElementImage',\r\n\t\t\t\t\t\t\t'data[ImageFile][foreign_key]': $scope.element.CmsPageElement.id\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t\tfile: file,\r\n\t\t\t\t\t\tfileFormDataName: 'data[ImageFile][file]'\r\n\t\t\t\t\t}).progress(function (evt) {\r\n                                            /* ... */\r\n\t\t\t\t\t}).success(function (data, status, headers, config) {\r\n                                            /* ... */\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t});\r\n```"}}