Unable to resize photo in App Inventor

No.

Why didn't you try my test aia?

Hi @Anke, i've already tested your aia, and when i used it, the image size on your aia is around 10 kB. so i tried it on my app and made it like yours (but in resize block i make it around 320*240) but the result is around 895 kB and the resolution still 2640x1488 px. and the photo unable to uploaded to my google script, is there something that i did wrong?

In order to:

  • Take a Picture
  • Rename that picture to have a jpg extension (this handles a naming bug in AI2 at time of writing)
  • Resize the picture (using Taifun's Image extension)
  • Convert picture to a base64String (using Juan Antonio's Base64 extension)
  • Upload the picture to Google Drive (using the script below, and a designated folder)
  • We know the mime-type will be jpeg because we have a .jpg image file
  • We use the camera assigned filename because of the timestamp

...

SCRIPT
function doPost(e) {
    var data = Utilities.base64Decode(e.parameters.data);
    var blob = Utilities.newBlob(data, e.parameters.mimetype, e.parameters.filename);
    var fileID = DriveApp.getFolderById(e.parameters.folderId).createFile(blob).getId();
    return ContentService.createTextOutput(fileID);
    }

...

BLOCKS

1 Like

Hi there!

I've followed your blocks and script but still I couldn't uploaded it on Google Drive Folder, is there something wrong?

Sorry if i may irritated you guys, it's my first time to make the app and have zero experiences, and I'm glad this community could help me :')

here's the result from my phone (Samsung S9)

This is an error from your blocks - somewhere - you will need to debug your workflow to find where the error occurs

I've followed the blocks exactly as yours to make dummy, ensure where did I went wrong. but still nothing's happen.

I do really need your help, i've tried but still nothing happened. and unable to resize the images cause a lot of time to remove it one-by-one to prevent my drive "full capacity".

and this is the script

OK, this problem has now moved to the google apps script side of things.

Please show the complete responseContent returned, the error is usually at the end!

Also check that you have deployed your script correctly, and that the latest script url matches the one in your blocks

This is the result

OK, you are getting a page not found web page being returned.

Check again your script url and FolderID are correct. Redeploy your script.

what's supposed to be as the result? still i haven't managed it even i've recheck the redeployment and the folders

Your script should return the fileID of the file you are uploading

Can you share your aia project for testing

coba.aia (56.0 KB)

This is based on your blocks

And this is my project ABSENBETA.aia (2.6 MB)

you might login in it with user:000000 pass:000000

Two errors in your blocks, a typo pictures instead of Pictures and not using the ASD FileToString block.

You should be testing all this.

However still returns a Page not Found - Sorry, unable to open the file at present - not surer which file it means.

image

How are you saving your script ? Should be Anyone, not Anyone with a google account

and just found another error in your blocks....was .UriDecode should be UriEncode

Finally! Thank You guys, but then how i can change the name of the picture into the name that i want, first the name of the resized photo was (app_inventor_1640948660038), and i want to change it based on (name_date_hour)

What was it that fixed your problem ?

You can name your file whatever you want, just set that to the filename variable.
You can use the number part of the filename created by the Take Picture, this is the time/date in milliseconds.

Something like this:

I've followed your script and blocks, and it works. But i have problem can't add timestamp like in this image, could you please help me how to do that? Thanks.

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