> For the complete documentation index, see [llms.txt](https://docs.specifyapp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.specifyapp.com/reference/parsers/to-bitmap-file.md).

# to-bitmap-file

## Interface

```typescript
interface parser {
  name: 'to-bitmap-file';
  options: {
    filenameTemplate: string;
  };
  output: {
    type: 'directory';
    directoryPath: string;
  };
};
```

## Options

<table><thead><tr><th width="216">Parameter</th><th width="100">Required</th><th width="100">Type</th><th width="483">Default</th><th width="507">Description</th></tr></thead><tbody><tr><td><code>filenameTemplate</code></td><td><code>false</code></td><td><code>string</code></td><td><code>"{{parents}}/{{name}}[-{{mode}}]{{extension}}"</code></td><td>The mustache template used to generate the file path to write to the file system.<br>Available variables:<br><code>parents</code>: group and collection names of the token's parents<br><code>name</code>: the name of the asset token<br><code>mode</code>: the name of the current mode<br><code>extension</code>: the file extension extracted from the token</td></tr></tbody></table>

## Basic usage - single mode

{% tabs %}
{% tab title="Input" %}
{% code lineNumbers="true" %}

```json
{
  "assets": {
    "image": {
      "$type": "bitmap",
      "$value": {
        "1x": {
          "url": "<url-of-your-bitmap-file>",
          "format": "png",
          "width": 623,
          "height": 415,
          "variationLabel": null
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="Config" %}
{% code title=".specifyrc.json" lineNumbers="true" %}

```json
{
  "version": "2",
  "repository": "@organization/repository",
  // Only use the personalAccessToken when working with the CLI
  "personalAccessToken": "<your-personal-access-token>",
  "rules": [
    {
      "name": "Generate images",
      "parsers": [
        {
          "name": "to-bitmap-file",
          "output": {
            "type": "directory",
            "directoryPath": "public"
          }
        }
      ]
    }
  ]
}
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}
This will generate a single bitmap file like so:

* public/assets/image.png
  {% endtab %}
  {% endtabs %}

## Advanced usage - Several modes by definition (@1x, @2x...)

Our bitmap is named "image", is in a group named "assets", and has 2 modes for each definition parameter: 1x and 2x.

By default, this parser will generate the following output: `{directoryPath}/{groups}/{bitmapName}.{png|jpg}`

{% tabs %}
{% tab title="Input" %}
{% code lineNumbers="true" %}

```json
{
  "assets": {
    "image": {
      "$type": "bitmap",
      "$value": {
        "1x": {
          "url": "<url-of-your-bitmap-file>",
          "format": "png",
          "width": 623,
          "height": 415,
          "variationLabel": null
        },
        "2x": {
          "url": "<url-of-your-bitmap-file>",
          "format": "png",
          "width": 1246,
          "height": 830,
          "variationLabel": null
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="Config" %}
{% code title=".specifyrc.json" lineNumbers="true" %}

```json
{
  "version": "2",
  "repository": "@organization/repository",
  // Only use the personalAccessToken when working with the CLI
  "personalAccessToken": "<your-personal-access-token>",
  "rules": [
    {
      "name": "Generate images",
      "parsers": [
        {
          "name": "to-bitmap-file",
          "output": {
            "type": "directory",
            "directoryPath": "public"
          }
        }
      ]
    }
  ]
}
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}
This will generate the following bitmap files:

* public/assets/image-1x.png
* public/assets/image-2x.png
  {% endtab %}
  {% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.specifyapp.com/reference/parsers/to-bitmap-file.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
