Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Titanium SDK helper to resize
function resizePhoto(blob, size) {
var measurement = require('alloy/measurement'), w, h;
if (blob.width / blob.height >= size.width / size.height) {
w = measurement.dpToPX(size.width);
h = blob.height * measurement.dpToPX(size.width) / blob.width;
} else {
w = blob.width * measurement.dpToPX(size.height) / blob.height;
h = measurement.dpToPX(size.height);
}
result = blob.imageAsResized(w, h);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment