Image optimizer : Optimize images and reduce it's size


It is no problem when I tried to upload photo to Google Drive ,but it’s fail if I resize photo file size and upload photo to Google Drive.

I want to try to resize photo and upload to Google Drive , not only upload photo.

:grin: :grin: :grin:

I tried to upload photo to Google Drive. ↓↓↓

Upload photo to Google Drive Upload photo
Base64 .aix

And studied to resize photo file size. ↓↓↓

Photo Resize

it’s fail if I resize photo file size and upload photo to Google Drive. I have been trying to figure out this question for three months but still have no idea.

  1. Please show your relevant blocks
  2. Where is your image coming from - the camera ?

Using an image in the assets I have it working here:
I used my ImageBase64 extension to get the base64String from the optimised image displayed in the image component

Script as follows:

function doPost(e) {
    var data = Utilities.base64Decode(;
    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);


Hi Sir

My blocks ↓

my photo upload to Google Drive .aia

  1. My image from to imagepicker.

This .aia is Chinese.

I know your blocks, it's photo upload

Thank you.

But, I want to try to resize photo and upload to Google Drive, not only upload photo.

:grin: :grin: :grin:

Yes, my blocks optimise (resize) then upload.

Looks like you are trying to upload four images at once. This will not work. Do them one at a time in a loop, using the Web1.GotText to start the next upload.


Your Button1 is resize image and Button2 is upload image?


Sorry, my English is not good.


Yes, that is correct.


I don't have your block base64...

my use base64

I provided a link for it 7 posts up :slight_smile:

However, if you rework the blocks a bit, you can continue to use your chosen base64 extension.

Thank you, sir

I need some time to research

Rework? I do not understand what you mean.

First of all, uploading four photos is totally fine, but when I tried to combine with the compression function, it fail even I only compress and upload one photo, the photo was uploaded without any compression. Maybe it because the composition module still uploads four pictures at once?Do I have to use the loop method to compress and upload multiple photos?

I would.

Setup a routine that selects the image, optimises it, then uploads it, then move to the next image to do the same.

1 Like


I will use your study of block, thank you.

Hello Kumaraswamy,
I am new to MIT app inventor so unable to use your code can you please share video for image optimizer that will helpful for all other new bies like me.

If you're a newbie, you should start with something else such as simple tasks. Once you've mastered the basics, you can move on to extensions.

Hello Gordon_Lu,
thank for your high IQ level suggestion.

Hi buddy, this is not work, maybe i get wrong block buddy? thanks


See the documentation in the first post, especially:

Your file path is most probably incorrect