Excel Function: IMAGE
Purpose
The IMAGE function retrieves an image from a location specified by a URL and inserts it into a cell.
- Images can be sorted.
- The IMAGE function has 4 modes of operation:
- The image is fit to the cell and its aspect ratio is preserved.
- The image is fit to the cell and its aspect ratio is ignored.
- The image is displayed full size.
- The image’s height & width is specified with arguments passed to the IMAGE function.
Invocations of the IMAGE function take the form:
IMAGE(source,[alt_text],[sizing],[height],[width])
Limitations
- The protocol of the URL passed to the ‘source’ argument must be HTTPS.
- Support for image formats is limited to: BMP, JPG, JPEG, GIF, TIFF, PNG, ICO, and WEBP.
- WEBP is not supported on Excel for the Web, or Android.
Arguments
Argument | Argument type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
source | Mandatory | Represents a URL at which an image is accessible. The URL must use the HTTPS protocol. | ||||||||||
alt_text | Optional | A description of an image, intended for people who are visually impaired. | ||||||||||
sizing | Optional | Dictates how an image should be sized. It can assume one of four values:
| ||||||||||
height | Optional | An image’s height in pixels. Mandatory if sizing has a value of 3. | ||||||||||
width | Optional | An image’s width in pixels. Mandatory if sizing has a value of 3. |
Related Functions
Function | Example | Purpose |
---|---|---|
ENCODEURL | IMAGE(ENCODEURL(source)) | Sanitise a URL, then retrieve & display the image located at it. |
Error Conditions
The IMAGE function will respond with an error value if any of the following conditions are met.
Error value | Condition type | Condition |
---|---|---|
#VALUE! | Bad argument | An attempt was made to get an image with an unsupported format. |
#VALUE! | Bad argument | An invalid URL was supplied to the source argument. |
#VALUE! | Bad argument | The sizing argument’s value was 3 and height and/or width were omitted. |
#VALUE! | Bad argument | The sizing argument’s value was 3 and height and/or width were ≤ 0. |
#VALUE! | Bad argument | The sizing argument’s value was 0, 1 or 2 and height and/or width were provided. |
#CONNECT! | Runtime | It was not possible to access the image. |
#BLOCKED! | Runtime | The image exists but access to it was denied. |
Example 1: Sizing Type 0
Formula
=IMAGE("https://img.icons8.com/?size=512&id=12510&format=png","Sizing type: 0",0)
Result
Example 2: Sizing Type 1
Formula
=IMAGE("https://img.icons8.com/?size=512&id=12510&format=png","Sizing type: 1",1)
Result
Example 3: Sizing Type 2
Formula
=IMAGE("https://img.icons8.com/?size=512&id=12510&format=png","Sizing type: 2",2)
Result
Example 4: Sizing Type 3
Formula
=IMAGE("https://img.icons8.com/?size=512&id=12510&format=png","Sizing type: 3",3,100,100)
Result
Example 5: Sorting Images
Columns containing images retrieved by the IMAGE function can be sorted. Excel sorts them by alt_text then by source.