Image to Base64 Extension


#2

after words base64; there is a Base64 string, which is an image. Just in string format.


#3

I can make an API for you if you want


#4

API? But even if you make an API, I will still have to upload an image to your server which will not make images upload faster, or I am missing something?


#5

Oh, you wanted image to Base64…
I thought you were talking about Base64 to image :sweat_smile:


#6

Yea, image to Base64. If anyone can make it, it would be amazing. @Mika you were searching ideas. This would help me a lot of, if you can make it.


#7

You can use this extension :

com.ghostfox.SimpleBase64.aix (6.0 KB)

The extension has two simple functions :

  • EncodeImage

  • DecodeImage

EncodeImage

Converts the image specified with the path to a Base64 String

DecodeImage

Converts the Base64 String to an image that is displayed in the Image component .

Permissions needed : android.permission.READ_EXTERNAL_STORAGE to convert images from the external SDcard

If you need any other functions , please post here or send a PM :wink: .


Audio .3gp to Base64 Extension
Best way to hide firebase token?
#8

Amazing job! Thank you! By the way, can you fix 1 issue? AfterPicture event (Camera’s component) gives a URI type of path: file:///mnt/sdcard/image.jpg. Ok, thank you for contributing to OpticalMath & community!


#9

That is not an issue .
Just replace the text or use split at .


#10

Ok, thank you! I tried to make this extension by myself, but I have failed! Thank you for great work again, @Sivagiri_Visakan I am sure that you in future gonna be the best extension developer :slight_smile:. Because, you did make OAuth support thing.


#11

You are welcome !

Thank you but I would prefer the term “one of the best” developers :smile: :grin:
There are many others who also work hard to make extensions !


#12

Your extension doesn’t work.

My app stops responding.


#13

Isn’t the path returned as file:///mnt/sdcard/image.jpg ?
If yes,then you have to replace file:///mnt/


#14

@Sivagiri_Visakan could your base64 decoded image be stored as a file and how?


#15

Extension takes too much time to encode an image. My image uploads to Cloudinary faster than this extension encodes image. Also, if you use AfterPicture event & EncodeImage function, it will show black screen for 1minute (this happens while EncodeImage is encoding image). Users just gonna think that my app is lagging (not responding) and etc. Image to Base64 converter should take max of 3 seconds to convert img. Sorry, I cannot use it. By the way, users should not use this extension in production-ready apps. This extension needs a bit of more work.


#16

Add function argument “Quality”.
compress(Bitmap.CompressFormat.JPEG, quality, baos);
So users could change quality, because if user compresses original image, it would take too much time. I prefer 50%


#17

I will add this in the next version

I will see if I could bring out a fix and make it such that it doesn’t stop the app till the image is encoded .

Will add it in the next version.

Thank you all for your suggestions and patience.


#18

Thank you. To add quality, simple add Quality parameter and change compress(Bitmap.CompressFormat.JPEG, 100, baos); to ompress(Bitmap.CompressFormat.JPEG, quality, baos);


#19

@Sivagiri_Visakan, I found a simple solution to store image with tinyDB by means of your useful extension!
(here the image1 is only needed to confront the image picked with image saved in tinyDB and then shown in image2)


#20

Does it not lag?


#21

Yes ! It is indeed a great example ! Thank you for using the extension !

Like @ILoveThunkable asks, does it lag when you use the EncodeImage and DecodeImage function ?