Problem
After taking a picture in android with the code below the application creates 2 files in the next path:
/sdcard/DCIM/camera/
One of them is named with the initials tiaxxx.jpg
Reproducible steps:
1. Run the code below
2. Take a picture
3. Go to the next path: /sdcard/DCIM/camera/
Notice that in the above path is created a file with the name of tiaxxx.jpg
Expected behavior:
Customer does not want to have another image stored with the name Tiaxxxx.jpg in the next path: /sdcard/DCIM/camera/
More info:
I use saveToPhotoGallery:false too, but it's the same expected behavior.
Sample code:
var mwin = Ti.UI.createWindow({
backgroundColor : 'orange'
});
var btnShowCamera = Ti.UI.createButton({
title : 'Take picture',
width : 150,
height : 70,
top : 50
});
mwin.add(btnShowCamera);
btnShowCamera.addEventListener('click', function(e)
{
Titanium.Media.showCamera(
{
mediaTypes : Titanium.Media.MEDIA_TYPE_PHOTO,
allowEditing : true,
saveToPhotoGallery:true,
success : function(event)
{
//var cropRect = event.cropRect;
var image = event.media;
var imageView = Titanium.UI.createImageView(
{
image : image,
width : 480,
height : 640
});
image = imageView.toBlob();
if(Titanium.Filesystem.isExternalStoragePresent())
{
var photoDir = Titanium.Filesystem.getFile(Titanium.Filesystem.externalStorageDirectory, 'PlayGroundPhotos');
if(!photoDir.exists())
{
photoDir.createDirectory();
}
}
var photoPath = photoDir.nativePath;
var f = Titanium.Filesystem.getFile(photoPath, 'tony.jpg');
f.write(image);
},
cancel : function()
{
},
});
});
mwin.open();
Helpdesk
APP-344567
Similar behavior observed. Duplicate images with different file names are stored in gallery. code:
var win = Ti.UI.createWindow(); Titanium.Media.showCamera({ success:function(event) { // called when media returned from the camera Ti.API.debug('Our type was: '+event.mediaType); if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { var imageView = Ti.UI.createImageView({ width:win.width, height:win.height, image:event.media }); win.add(imageView); } else { alert("got the wrong type back ="+event.mediaType); } }, cancel:function() { // called when user cancels taking a picture }, error:function(error) { // called when there's an error var a = Titanium.UI.createAlertDialog({title:'Camera'}); if (error.code == Titanium.Media.NO_CAMERA) { a.setMessage('Please run this test on device'); } else { a.setMessage('Unexpected error: ' + error.code); } a.show(); }, saveToPhotoGallery:true, allowEditing:true, mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO] }); win.open();Setting saveToPhotoGallery to true will automatically save the image in device photo gallary. If I set this to false, I don't see the extra file getting created. Tested with SDK 3.1.0 using Google Nexus.
Closing ticket as the issue cannot be reproduced.