Limitation of Images for Inserting to Spreadsheet using Google Apps Script

Gists

Introduction

Here I would like to introduce about the limitation of images for inserting to Spreadsheet using Google Apps Script (GAS). When you want to insert the images to Spreadsheet using GAS, insertImage() of class Sheet is usually used for this situation. At this time, an error sometimes occurs. This indicates that there is the limitation for inserting images to Spreadsheet. So I investigated the limitation.

As a result, it was found that the limitation depends on the image area (pixels^2) rather than the file size of it. The maximum area of image which can be inserted was 1,048,576 pixels^2.

Experiment

In order to investigate the limitation, I have converged the condition by changing the file size and the image size. By this, it was found that the limitation depends on the image area (pixels^2) rather than the file size of it. For this confirmation, I can show you the following experimental data.

  • Image with the following sizes can be inserted.
    • 1024 pixels x 1024 pixels
    • 2048 pixels x 512 pixels
    • 4096 pixels x 256 pixels
  • Image with the following sizes can NOT be inserted.
    • 1025 pixels x 1025 pixels
    • 1024 pixels x 1025 pixels
    • 1025 pixels x 1024 pixels

From these data, I concluded that the limitation of area was 1,048,576 pixels^2. This limitation is applied to png, jpeg and gif.

Summary

In this report, I have investigated the limitation of images for inserting to Spreadsheet using Google Apps Script.

  • It was found that the limitation depends on the image area (pixels^2) rather than the file size of it.
  • The maximum area of image which can be inserted was 1,048,576 pixels^2.

As a note, this result was obtained at July 10, 2018. When this result might be changed by Google’s update. If the limitation was changed, I would like to update this report. And also, if this result was wrong, I would like to modify this report.

References :

 Share!