Skip to content

Instantly share code, notes, and snippets.

@minhnc
Created March 9, 2012 00:02
Show Gist options
  • Save minhnc/2004245 to your computer and use it in GitHub Desktop.
Save minhnc/2004245 to your computer and use it in GitHub Desktop.
PhotoGallery - Detect media width/height
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