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; }