Convert image to Base64 and vice versa

Hello everyone!
sorry for my bad english.
This is the first time in this forum.
I have a base64 image and conversion problem.
I use the extension “com.ghostfox.SimpleBase64.aix”
after pressing the “Decode” button, I cannot copy the image of the block “image1” to the block “image2”.
this is the App Design


and these are the blocks.

can someone help me?

Thank you all

where do you set Image1.Picture to the picked image? I can’t see it in your screenshot…
Taifun

Hello
thanks for the immediate reply.
“Image1” is set on the “Simplebase641 --> DecodeImage” block

Just use the DecodeImage block again but for Image2 ?

What do you see in Label1.Text ? (after decode)

I know I can use “DecodeImage” again, but I wanted the problem is that I can’t understand why I can’t use the image that is in “Image1” to be able to transfer it to “image2”.
from what I seemed to understand is that once I have inserted the image in “image1” it is no longer possible to manage it in any way.
for label1 you are right it is an error that remained in one of the many tests carried out.

I believe you will need a file to do this. Try with Juan Antonio’s base64 extension:

blocks (38)

Hello

I had already tried this “extension”, but in this way I am forced to know exactly the name and position of the image.
The goal was instead to search for images through the gallery (simpler) with a block “ImagePicker”

It doesn’t force you at all! You could overwrite the image picker selection file
Just use the imagepicker selection block as the filename for FileToString

If you want to return the image later, save the value of imagepicker.selection to a variable or tinydb

In production (compiled app) you may need to get WRITE_EXTERNAL_STORAGE permission

it works perfectly
in case of other problems I will disturb you again
thanks for everything to everyone

Hello
maybe I exulted too early. I think your suggestion doesn’t work.
Everything seems to work but in reality the images are displayed only because they are still stored in “ImagePicker Selection” and not because they are converted by the “StringToFile” block.
In fact, even if you deselect the “StringToFile” block, the program works the same.
immagine
Also, if I insert a label2, I should see the return value “string” of the conditional base64 in the block “Got string”, but instead it returns “file not found”.
immagine
can help me

thanks

what about using a filename in the StringToFile method rather than imagepicker1.selection?
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

OK, but the goal is to take an image / photo from the gallery regardless of whether it is the local or on sdcard and without knowing its specific path

the StringToFile method converts a base64 string back into a file. This method is independent of picking any image using the image picker… using imagepicker1.selection as filename does not make much sense therefore IMHO

Taifun

Hello Taifun

maybe I made some confusion myself.

what i need is this:

  1. take an image from the gallery via an “ImagePicker” block
  2. convert this image to a “Base64” string
  3. store the string obtained in a TynyDB or SqLite database
  4. reload the string from the database
  5. convert it into an image
  6. insert it in an “Image” block
  7. to be able to copy the image just loaded into a variable or another “Image” block or canvans

can you help me?

Thanks in advance

Try this

hi Juan_Antonio

i tried and it works

thank you very much

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.