Taking photos and compressing them before send to a server

There are several extensions available for resizing/compressing images

Thanks for replying @TIMAI2, most of them (I've seen one or two) are redirected to web.archive.org which does not have any link to download. Anyway, I'll searching in other places in order to find it. Thank you.

You can try this:

Image Convertor

1 Like

Thank you!!!

Do you have any example of use? My goal is to take a picture, compress it (or resize it) and after this convert to base64 string and save into a table from SQLite.

Try here:

target = file to be converted
output = destination and filename of converted file.

1 Like

Thank you!! Will try it now.

Do you wish to put a limit on size? Like compress an image to 200 kb or less.

1 Like

Hi, a simple way to resize the image taken is to use canvas,

  • add a canvas on your screen app, with your favorite size
  • take a picture and set the canvas background with the image taken
  • the image is automatically resized with the canvas size
  • use canvas saveas to save the image resized
    canvas

Best Regards
Marco

3 Likes

..... that might degrade image quality, so best to make a small test app to see if it is satisfactory for the project.

You can reduce the byte size just by converting the camera's jpg image to webp.

An extension that can reduce the dimensions and compress, all quickly done without the App User having to make an input might be the way to go.

1 Like

Exactly!!! What I need is to to do this, save it in SQLite and after send to a remote server (MySQL).

Hi @ChrisWard

I've tested this extension. Do you think it is a good one?

Another question is: How do you deal with saving images into a SQLite table? I tried to save the photo (in Base64 string) and I noticed that companion stops working. So what are your experiences about it?

Maybe I have to open a new post about it...

......I have never used it and I don't know the developer.

Developer reputation is important as extensions often require upgrades to work with new versions of Android and App Inventor.

1 Like

You are right!!

That's something that could be best to test as an APK rather than Companion.

1 Like

I'm testing now TIMAI2's extension.

1 Like

Understood.

If you want to store the images as base64 then you could do this:

  1. Take your Picture
  2. Set an Image component to the output size you want, e.g. 400x300 (it does not have to be visible)
  3. Set the taken picture "image" to the image component
  4. Use this extension to convert the imagePicture to base64
  5. Store the base64 string created to your sqlite record (you will need a TEXT field for the base64 string)

hmm, just been testing, extension does not appear to be working in companion for some reason!

2 Likes

Yeah, that's what I'm looking here too... companion stops working. Maybe I have to test with APK.