Created
March 9, 2012 00:02
-
-
Save minhnc/2004245 to your computer and use it in GitHub Desktop.
PhotoGallery - Detect media width/height
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
Titanium.Media.openPhotoGallery({ | |
success : function(event) { | |
// TODO: 2 WAYS TO GET WIDTH/HEIGHT OF EVENT.MEDIA | |
// 1. STORE IT TO FILE THEN GET W/H | |
// 2. event.cropRect.width/height | |
var cropRect = event.cropRect; | |
var filename = (new Date().getTime()) + "_tmp.png"; | |
var file = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, filename); | |
file.write(event.media); | |
var media = file.read(); | |
alert(media.width + ' - ' + media.height + ' - ' + cropRect.width + ' - ' + cropRect.height); | |
Titanium.API.info('PHOTO GALLERY SUCCESS cropRect.x ' + cropRect.x + ' cropRect.y ' + cropRect.y + ' cropRect.height ' + cropRect.height + ' cropRect.width ' + cropRect.width); | |
}, | |
cancel : function() { | |
}, | |
error : function(error) { | |
}, | |
allowEditing : true, | |
mediaTypes : [Ti.Media.MEDIA_TYPE_VIDEO, Ti.Media.MEDIA_TYPE_PHOTO] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment