media.capturePhoto() creates two image copies on device

Hi,

media.capturePhoto() creates two image copies on my android device.

It creates one copy in my “Camera shots” directory,

and after I restart the device, it shows another copy in “Pictures” directory in my gallery.

Code:

local function onComplete( event ) local photo = event.target print( "photo w,h = " .. photo.width .. "," .. photo.height ) end if media.hasSource( media.Camera ) then media.capturePhoto( { listener=onComplete } ) else native.showAlert( "Corona", "This device does not have a camera.", { "OK" } ) end

Does anyone have any ideas why is this happening?

Mladen

Hi @Mladen,

Can you determine if two actual copies of the image are being created? Or is it the same image (file) just being linked from the two different UI screens?

Brent

@ Brent,

Yes, there are two actual files created.

First is stored at: storage/sdcard0/Pictures,

and second one at: storage/sdcard0/DCIM/100MEDIA.

When I connect the device to PC, I can see same image in two different folders.

Screenshot:

https://www.dropbox.com/s/izvdyix0tgf6y44/Screenshot.png

Hi @Mladen,

Well, this may not be “normal”, but there is no standard camera app on Android, meaning that it’s up to the phone manufacturer to provide their own camera app, and almost every Android phone comes with a different 3rd-party camera app. How it works is that Corona will instruct the 3rd-party camera app to save the camera shot to external storage. Corona then reads that image from shared storage and makes it available as a display object via “event.target”. And basically that’s it… Corona never actually copies the image, unless you provide a destination, in which case Corona will attempt to “move” the file, as illustrated in this doc:

http://docs.coronalabs.com/api/library/media/capturePhoto.html#destination-optional

Hope this helps,

Brent

@Brent,

Thanks for your response.

Mladen

Hi @Mladen,

Can you determine if two actual copies of the image are being created? Or is it the same image (file) just being linked from the two different UI screens?

Brent

@ Brent,

Yes, there are two actual files created.

First is stored at: storage/sdcard0/Pictures,

and second one at: storage/sdcard0/DCIM/100MEDIA.

When I connect the device to PC, I can see same image in two different folders.

Screenshot:

https://www.dropbox.com/s/izvdyix0tgf6y44/Screenshot.png

Hi @Mladen,

Well, this may not be “normal”, but there is no standard camera app on Android, meaning that it’s up to the phone manufacturer to provide their own camera app, and almost every Android phone comes with a different 3rd-party camera app. How it works is that Corona will instruct the 3rd-party camera app to save the camera shot to external storage. Corona then reads that image from shared storage and makes it available as a display object via “event.target”. And basically that’s it… Corona never actually copies the image, unless you provide a destination, in which case Corona will attempt to “move” the file, as illustrated in this doc:

http://docs.coronalabs.com/api/library/media/capturePhoto.html#destination-optional

Hope this helps,

Brent

@Brent,

Thanks for your response.

Mladen