Skip to content

Instantly share code, notes, and snippets.

Created June 8, 2015 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/822957a13d0d8e2e5725 to your computer and use it in GitHub Desktop.
Save anonymous/822957a13d0d8e2e5725 to your computer and use it in GitHub Desktop.
Thumbnail
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