Android Question Is it possible to move/delete a pic taken by EZcamera?

clooney48

Active Member
Licensed User
Longtime User
I try now the EZcamera library to take pictures. It works fine but I would like to move the pictures to a certain directory. It is possible to copy the fresh taken pic to a certain directory but it is not possible to delete the original file in the DirRootExternal because the original name is not "TestPic.jpg". To be able to delete it I had to know the name which was created in the original camera directory.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim cam As EZcamera
    cam.Initialize("Cam")
    cam.TakePicture(File.DirRootExternal, "TestPic.jpg")
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub Cam_PictureTaken (FileSaved As Boolean)
    If FileSaved = True Then ToastMessageShow("Picture Saved " & File.DirRootExternal, True)

    File.Copy(File.DirRootExternal,"TestPic.jpg",File.DirRootExternal & "/Pictures" & "/NEW/","TestPic.jpg")
    File.Delete(File.DirRootExternal,"TestPic.jpg") '<< DOESN´T WORK BECAUSE OF NAME

End Sub
 

clooney48

Active Member
Licensed User
Longtime User
I think it creates a copy of the original file with the name "TestPic.jpg" while the original file is in the memory with this line:
B4X:
cam.TakePicture(File.DirRootExternal, "TestPic.jpg")
The original file is saved by the internal terminology, for example "img314.jpg". Therefore I have a pic named "TestPic.jpg" in my NEW Directory and the same pic as "img314.jpg" in my DirRootExternal.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Here is the full code you need without having to rename or move files around:
B4X:
Sub Globals
  Dim cam As EZcamera
  Dim MyFolder As String = "Pictures/NEW"
End Sub
 
 
Sub Activity_Create(FirstTime As Boolean)
  If File.Exists(File.DirRootExternal & "/" & MyFolder,"") = False Then
      File.MakeDir(File.DirRootExternal,MyFolder)
  End If
 
  cam.Initialize("Cam")
  cam.TakePicture(File.DirRootExternal & "/" & MyFolder, "TestPic.jpg")
End Sub
 
 
Sub Cam_PictureTaken (FileSaved As Boolean)
  If FileSaved = True Then ToastMessageShow("Picture Saved", True)
End Sub
 
Upvote 0

clooney48

Active Member
Licensed User
Longtime User
Hi Mahares!

Thanks, but the problem remains the same with my HTC One: I get on pic in the NEW dir and one pic in the original camera dir.
By the way: I would prefer to use the original file name instead of "TestPic.jpg" but this seems also not to be possible.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I ran the code I posted for you exactly as it is on 2 devices: One with OS4.2.2 and one with OS4.03. Both worked the way they should. There is only one file (with the name and path indicated) saved to the device, not two in different places.
Did you also consider CameraExClass class by Erel. It works quite well.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
That is the same library I used for the code I gave you (version 1). it works fine for me. I am not sure there is another version.
 
Upvote 0
Top