Merge Images

How do I dynamically mail merge images, QR codes, and barcodes?

This article describes how to merge images that have a public URL. Such images can come from Google Search, Google Drive, or online services that generate QR codes and barcodes from a URL.

Merge images from a public URL

This section describes how to merge a generic image with a public URL, irrespective of the origin of the image.

NOTE: If you wish to merge images from Google Slides to Google Slides Presentation files, refer to this article.

Video tutorial

Watch this quick tutorial or follow the step-by-step instructions below to find out how to merge to images from Google Docs.

Step 1: Create new column with <img> tag

In Google Sheets, create a new column and name it whatever you want, but include the tag <img> (e.g., Profile Photo <img>)

This column forms the basis for being able to add images to your mail merge.

Step 2: Paste image URLs

Paste your image URL in the applicable cells of your new column (with the <img> tag).

Your image URL can come from a variety of sources such as Google Search, Google Drive, an image hosting service, or online services that generate QR codes and barcodes from a URL. See the section below to find out how to obtain your image URL.

Repeat the steps above for each image that you want to merge.

This enables a mail merge image to be specified for each row to be merged.

NOTE: The image URL cannot be more than 235 characters in length.

Step 3: Insert image *|merge fields|*

In your merge template, insert the image *|merge field|* as you would for any other merge field (e.g., *|Profile Photo <img>|*)

Your mail merge picture is displayed in the location where you insert your *|merge field|*.

Merge Template

Merged Content

Obtain image URL

This section describes how to obtain your image URL from Google Search, Google Drive, or online services that generate QR codes and barcodes from a URL.

Google Search

Search for your image using Google Search, as shown in the example below. 

Right-click on the public image, and then click on Copy image address.

This copies the image URL from Google Search, ready to be pasted into your Google Sheet.

Google Search can be used to find photos to mail merge, as well as many other image types.

Google Drive

Note: Using Google Drive to host your image may not work for every merge as Google Drive uses URL redirection. It is recommended that you use an image hosting service instead of Google Drive (see section below).

Step 1: Host image on Google Drive

If your image is already hosted on Google Drive, proceed to Step 2.

If not, upload your image to Google Drive by clicking on New > File Upload and selecting your image file.

Google Drive then hosts your image to mail merge online.

Step 2: Click Get Link

Once your image file has uploaded, right-click on the image file in Google Drive, and then click on Get Link.

Step 3: Select Anyone with the link

Click on the access settings drop-down menu, and then select Anyone with the Link.

This makes sure that your mail merge picture can be accessed and merged by Mail Merge add-on.

Step 4: Copy image URL

Click on Copy Link to copy the image URL from Google Drive.

Your image URL is now ready to be pasted into your Google Sheet to add the image to your mail merge.

Image Hosting Service

Using an image hosting service that provides a direct image URL such as postimage.org can be more reliable than using Google Drive to host your images.

Step 1: Click Choose images

On postimage.org, click on Choose images and select the image(s) that you wish to upload.

The image file(s) uploads to postimage.org.

Step 2: Click Share

Click on Share for the image.

Step 3: Click copy icon

Click on copy icon next to the Direct link for the image to copy the image URL from postimage.org.

Your image URL is now ready to be pasted into your Google Sheet to add the image to your mail merge.

QR Code

Create your QR code using an online service such as Google Charts QR Codes or Image Charts.

Copy the image URL for your QR code.

An example mail merge QR code created using Google Charts QR Codes can be found below, along with its parameters and URL.

Root URL: https://chart.googleapis.com/chart?

QR code: cht=qr

Image size: chs=128x128

Data to encode: chl=samuel%20reeves

Complete QR code URL: https://chart.googleapis.com/chart?cht=qr&chs=128x128&chl=samuel%20reeves

You can quickly create a unique mail merge QR code for each data row by using a formula in your Google Sheet (see the screenshot below).

Barcode

Create your barcode using an online service such as Online Barcode Generator.

Copy the image URL for your barcode.

An example mail merge barcode created using Online Barcode Generator can be found below, along with its URL.

You can quickly create a unique mail merge barcode for each data row by using a formula in your Google Sheet (see the screenshot below).

Advanced feature: Resize original image

You can specify the width and height of the image (in pixels) within the <img> tag.  

In the example below, the column header Profile Photo <img|200x100> would resize the image width to 200 pixels and height to 100 pixels for all mail merge photos within that column.

NOTE:  Any change of image size within your column header needs to be replicated in the corresponding *|merge field|* of your merge template (and vice versa).

Advanced feature: Combine strings of text for image URL

You can combine multiple strings of text by using the & character in the Google Sheets formula bar (see screenshot below). This is especially useful for mail merging QR code and barcode URLs.