Created
June 8, 2015 16:20
-
-
Save anonymous/822957a13d0d8e2e5725 to your computer and use it in GitHub Desktop.
Thumbnail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CapturedData.CreateThumb = function(file, w, h) { | |
var deferred = $q.defer(); | |
console.log('3. criacao do thumb'); | |
var nameid = GenRandom.id(); | |
if (file == null || file == undefined) { | |
console.log('Erro: é necessário fornecer uma url para uma imagem'); | |
return false; | |
} | |
if (w == null || w == undefined) { | |
w = 0; | |
} | |
if (h == null || h == undefined) { | |
h = 0; | |
} | |
options = { | |
quality: 100, | |
storeImage: true, | |
filename: nameid + '.jpg', | |
directory: cordova.file.dataDirectory + '/pictures', | |
width: w, | |
height: h | |
}; | |
console.info('options', options); | |
window.imageResizer.resizeImage(IRsuccess, IRfail, file, w, h, options); | |
function IRsuccess(s) { | |
console.log('sucesso ao gerar thumbnail'); | |
console.log(s); | |
window.resolveLocalFileSystemURL(cordova.file.dataDirectory + '/pictures/' +s.filename, | |
function(s) { | |
deferred.resolve(s); | |
}, function(e) { | |
deferred.reject(e); | |
}) | |
} | |
function IRfail(f) { | |
deferred.reject('Erro ao gerar thumbnail:' + f); | |
} | |
return deferred.promise; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment