Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6357] Android: Duplicating file with another name on android after saving a picture

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-03-27T17:57:01.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsAndroid
Labelsexalture
ReporterFrancisco Antonio Duran Ramirez
AssigneeSunila
Created2011-11-29T13:19:09.000+0000
Updated2017-03-21T21:32:45.000+0000

Description

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

Comments

  1. Devang Gandhi 2012-03-30

    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();
       
       
  2. Sunila 2013-03-27

    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.
  3. Lee Morris 2017-03-21

    Closing ticket as the issue cannot be reproduced.

JSON Source