# Extract images (Ximage)

{% hint style="warning" %}
This feature may not be enabled for every tenant.
{% endhint %}

{% hint style="warning" %}
The legacy `Type3` service type includes full support for this feature. [Neuron](/build-spark-services/neuron.md) only includes support for `Ximage_metadata` Base64 string images.
{% endhint %}

Spark can return mapped images as part of the API response. This can be useful for using Spark services to feed image elements to a front-end.

## Map the images

Syntax: `Ximage_<parameter>`

1. Click on the target chart or image.
2. As described in [How to: Map inputs and outputs](/build-spark-services/map-inputs-and-outputs.md#define-a-named-range-in-excel), use the Name Box to create a Name for the image. See a demonstration of this step [here](https://www.youtube.com/watch?v=-s8FjjK3dTM).
3. When creating the Name, use the noted prefix defined in the syntax.
4. The remaining steps are similar to [Produce PDF reports (Xreport)](/build-spark-services/other-mapping-options/produce-pdf-reports.md#map-the-report).
5. After the service is uploaded to Spark, this can be tested in the [API Tester](/navigation/api-tester.md).
6. In the API Tester, in the Field view, there will be a list of all the `Ximages` defined in the workbook.
7. There is a field that can be used to define the `FileName` parameter of the API request. This is used to customize the resulting filename.
8. **Submit** the API request.
9. In the API response *JSON view*, the report object will include a link to the resulting image file.

{% hint style="info" %}
`Ximage` does not support Excel 3D charts.
{% endhint %}

## Return an image as a Base64 string

Syntax: `Ximage_metadata.<parameter>`

Images can be returned as a Base64 string. This can be easier to use than an attachment when integrating the API response to a front-end. This works when the image is defined as part of the [How to: Work with subservices](/build-spark-services/subservices.md#metadata-subservice).

The mapping procedure is the same as [#map-the-images](#map-the-images "mention").

## Return Original file size images

Syntax: `Ximageoriginal_<parameter>` or `Ximageoriginal_metadata.<parameter>`

`Ximage` will return an image that has been resized based upon its dimensions in an Excel file. To return an image in its original quality and file size, use the alternative `Ximageoriginal` mapping.

The mapping procedure is the same as [#map-the-images](#map-the-images "mention").

* This functionality supports JPEG or PNG images but not Excel charts
* You must also enable *Do not compress images in file* in *Excel Options* > *Advanced*.

![](/files/gt6Id4z1N6DwVPDne21T)

## **Example of `Ximage` mapping**

This service can be uploaded to Spark to use as a simple example.

{% file src="/files/-MdGy6aH9M4Ov40ovzyR" %}
Example File
{% endfile %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherent.global/build-spark-services/other-mapping-options/extract-images.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
