Image resize question

The file module has an option to set the width and height, it states that it will not impact the file on the device however does it actually generate a file with that height / width?

Essentially our app sends images to the server for a photo gallery, however with cellphone images becoming larger and larger these files can be large. Now we can do image processing on the server however any amount of pre-processing we can do would be great. So the question is

When setting the image height and width via the file module, does this actually create an image with that height and width or is it more akin to just setting 'height=‘100’ via html?


A new image is created with the given width / height.

I’d be very interested to hear some data points on the kind of size reduction you get via this approach!

Just so I understand correctly, if I do a getImage like below and set the width and height the ‘file’ object returned will be the new image object?

      source: "gallery", 
      saveLocation: "file", 
    width: 100, 
    height: 100 
}, function (file) { 
        type: 'POST',
        url: '',
        files: [file],
        success: function(data) {
            // done


Yup :slight_smile:

Specifically, on iOS we create a new, empty UIImage object and then transform and blit the original image into it.

On Android we create a new Bitmap from the original and apply a transformation matrix to it.

In both cases the process happens in-memory and returns the resultant binary image data directly to forge.request so it’s not cluttering the disk or gallery with extra files.

Is the same true if you base64 the image as well? I have noticed on android, this seems to be the case but on ios it is the full size when sending it up to the server

base64 unfortunately follows a completely different code-path, it was never designed for big files or images for that matter.

Hi Antoine,

I was doing some additonal testing with this and noticed that IOS is not honoring the resized image but android is.

IOS ( ios 13 uploads the full image ) where android upload the correct image size. Any thoughts?

Also, module is up to date, we are also streaming the file object.