{"action":"created","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":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-02-16T09:34:21Z","updated_at":"2015-12-10T03:40:33Z","closed_at":"2015-02-16T11:06:27Z","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```"},"comment":{"url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/comments/163478057","html_url":"https://github.com/danialfarid/ng-file-upload/issues/568#issuecomment-163478057","issue_url":"https://api.github.com/repos/danialfarid/ng-file-upload/issues/568","id":163478057,"user":{"login":"danialfarid","id":1676054,"avatar_url":"https://avatars.githubusercontent.com/u/1676054?v=3","gravatar_id":"","url":"https://api.github.com/users/danialfarid","html_url":"https://github.com/danialfarid","followers_url":"https://api.github.com/users/danialfarid/followers","following_url":"https://api.github.com/users/danialfarid/following{/other_user}","gists_url":"https://api.github.com/users/danialfarid/gists{/gist_id}","starred_url":"https://api.github.com/users/danialfarid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danialfarid/subscriptions","organizations_url":"https://api.github.com/users/danialfarid/orgs","repos_url":"https://api.github.com/users/danialfarid/repos","events_url":"https://api.github.com/users/danialfarid/events{/privacy}","received_events_url":"https://api.github.com/users/danialfarid/received_events","type":"User","site_admin":false},"created_at":"2015-12-10T03:40:33Z","updated_at":"2015-12-10T03:40:33Z","body":"I don't think that is possible, the file information you get from the browser when you select the file through popup is very limited, only type, size and name. You need to load the image in the browser to get the image dimensions."}}