Camera component: Change filename of image?

Hello,

is there a way to change the filename of the image i made with the camera component?

The camera component saves it like kodular_1593834050903483.jpg and I want to change it to kodular_001.jpg or something.

Just use rename block in the file tools exetnsion after the image has been captured.
Edit: i thought it was in the file compoennt then i realized it isn’t it so i renamed it to another available extensions
Edit2: it’s even not available in taifun file extension
Edit3: @Soham_Shah mentioned the right extension first.But i suggested the right method first :crazy_face:

Use the rename file block of filetools extension, and set the filename parameter to kodular_1593834050903483.jpg or whatever the filename camera component stores as… and in the newfilename parameter set whatever name you want to rename as

@Mohamed_Tamer please write edit in your post so that user comes to know that I had mentioned filetools first, then you edited your post from file component to filetools extension

Np but you should always use Edit while editing post so that the user comes to know who had mentioned the right solution first :grinning:

Also please mention that i suggested the right extension first

I would avoid it,

as this is a time stamp and easier to distinguish the images, otherwise you have to come up with a system that counts up.

Save counts up locally, online db etc, check
TinyDB, File - user can delete it
Online db - no internet
Check how many images there is +1 - user might delete many of them
etc

I would prefer, after images is taken using notifier with save image as…

2 Likes

Thanks for all the replys.

My problem is:

I use the “File”-component to save a taken picture from the camera-Component to the “app-internal” storage, so that no other apps can access this. I need to store ONLY ONE picture. If another picture is made by the camera-component, it HAS TO override the older one.

As in documentation written, if I do not use “/” , the file (the picture from camera-component) is saved in the app-internal storage. But the picture also appears in “my files/pictures”. This is not intended. How can I avoid this?

You can check if the file exists first before saving.
If you are using kodular’s file component.
https://docs.kodular.io/components/storage/file/#exists

By default android store the picture into /Pictures …
Maybe with move option you can store the picture into app-internal

The picture is saved as kodular_159826787898.jpg (similar).

Where is the file Name “qrcode” saved to?

or did I not understand something?

1 Like

Nope.That isn’t what we mean.You can’t save it using the file component.After Picture event means that its already saved.And you can’t save it again.What you will make is that you will just rename the photo saved from its path ( you will get it in the image variable ) to the new file name using file tools extension.You can set the old file name as the image variable And set the new file name to qrcode.png for example.And whenever you will need to set an image to you will use set image property to the new image path. :slightly_smiling_face:
/storage/emulated/0/qrcode.png

It is saved to the Private directory.

Companion:

/storage/emulated/0/Makeroid/data/qrcode

Your blocks should look line this:

/storage/emulated/0/Makeroid/data/qrcode.txt

Explain what exactly you plan / want to achieve.

Since the default camera doesn’t have any properties I would btw, suggest using this App Inventor Extensions: Camera | Pura Vida Apps

1 Like

The landfill in my district only allows bulky waste and so on to be deposited for the residents of the district. You have to prove this by showing the waste fee notice or the QR code on it. Now it is awkward to take a picture of the QR code and then search for a long time in the gallery to show it to the employee at the landfill. During this time there is a queue at the exit.

This is the reason for the app: You take a photo of the QR code, it is displayed in the center of the image. You open the app and the QR code appears immediately. Show it once, have it scanned and you’re done.

I would like that if the user receives a new QR code or would like to take another photo for other reasons, the previous code is completely deleted from the mobile phone for reasons of data protection and trust.

Please refrain from sending me examples of complete apps, mine is already finished, except for the problems I mentioned with the images.

I would like:

  1. Take a photo that is only saved in the app’s own memory.
  2. be able to delete the photo completely.
  3. ONLY ONE PHOTO can be stored in the app’s own memory, i.e. a new photo replaces the old one.

There is - even with the camera extension from Taifun - no possibility in Kodular or AI2 to set the path for the picture to the Private directory. This is only possible with the File component and there only with the File.SaveFile text method.

ok that means the camera component ALWAYS will make a picture and save it instant into the /Pictures-Folder.

The only way is to use the ASD (app-specific directory) for this.

Yes, the ASD can only be accessed by the app.

It is not possible to save a file (image) in the internal storage (private directory) with the existing components (extensions). This is only possible with …

image

This way?

Yes, but it is no problem to move it from this folder to the ASD (using the File component or the TaifunFile ext.) So each Picture taken from the Camera is moved to the same path (fileName) in the ASD. So there is always only one picture in the ASD taken by the Camera.

3 Likes

But you can also try to use the Camera extension from Taifun and check if it is possible to set the ASD path directly, without needing WRITE_EXTERNAL_STORAGE permission. The TaifunFile ext. does not need this permission to write to the ASD. I’m not sure if the same also applies to the camera extension (never used).

I stuck with the basic principle of files used in Android.

How can I read the file and display it?

image
This works as intended, but with a file in "internal storage/Pictures (public available)

image
This block is missing in taifuns extension file.extension