Skip to content

Instantly share code, notes, and snippets.

@tanaikech
Created Jul 9, 2018
Embed
What would you like to do?
Limitation of Images for Inserting to Spreadsheet using Google Apps Script

Limitation of Images for Inserting to Spreadsheet using Google Apps Script

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 :

@nCr78
Copy link

nCr78 commented Nov 21, 2022

The limitation is still there and it is also enforced when you export a sheet as PDF which contains any image bigger than the 1,048,576 pixels^2 you mentioned. The only solution I thought of is to split the image into chunks and place them into different cells (and correct their height + width) since the limitation only applies per cell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment