Created
January 28, 2016 14:57
-
-
Save falkolab/00a265ae9d0bab2e6c89 to your computer and use it in GitHub Desktop.
Titanium SDK helper to resize
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
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