# Extract

### Extract Raw Image

1. Extract the `ps2data/image/ff12/myoshiok/in/bin_menu/item_gra00.as7` file via the VBF Browser.
2. Create a directory and put the `ff12-as7.exe` file into it.
3. Navigate into that directory.
4. Press `Ctrl + L` to focus the address bar of the file explorer.
5. Press `Backspace`, type `cmd` and then press `Enter` to open the Command Prompt.
6. Type the following code into the Command Prompt:

```batch
ff12-as7.exe -u item_gra00.as7 item_gra00.raw
```

7. Press `Enter` to convert the .as7 to a .raw file.

### Extract Color Look Up Table (CLUT)

The `item_clut.bin` file contains the color of all 7 .raw images in order, each one being 1024 (0x0400) bytes.

The color data of `item_gra00.raw` is at `0x0000` to `0x0400`, the color data of `item_gra01.raw` is at `0x0400` to `0x0800`, and so on.

The start offset is `File Number * 0x0400`, and the end offset is `Start Offset + 0x0400`.

To load a raw image with its associated clut, you will first need to extract its clut from the `item_clut.bin` to its own file (.cl2). To do that:

1. Extract the the `ps2data/image/ff12/myoshiok/in/bin_menu/item_clut.bin` file via the VBF Browser.
2. Download `item_gra00.cl2` from the [#files](#files "mention") section (rename file number if necessary).
3. Open  `item_clut.bin` and `item_gra00.cl2` with a hex editor.
4. Copy the bytes from `0x0000` to `0x0400` in `item_clut.bin` (start and end offset depends on file number).
5. Paste the bytes into `item_gra00.cl2`, starting at offset `0x40`, therefore replacing all `0xFF` bytes.

### Merge Raw Image & Clut

Now that you have both the raw image and the clut, you can merge them. To do that:

1. Open `item_gra00.raw` with an image editor.
2. Once the image size is requested, provide it based on the calculation from [here](https://xeavin.gitbook.io/the-insurgents-handbook/textures/equipment-previews) (e.g. `64x6144`).
3. Save it by setting the file name to `item_gra00` and the extension to `.png`.
4. Open `item_gra00.png` with Optpix Image Studio.
5. Select the color palette right from the image. If its not there, press `Ctrl + L`.
6. Right-click on the color palette, select `load palette` and then open `item_gra00.cl2`.
7. Select `File -> Save As` from the top navigation bar (or use `Ctrl + Shift + S`).
8. Set the file name to `item_gra00` and the extension to `.png`.
9. Click on the `Save` button (changing file saving options isn't necessary).

### Notes

{% hint style="info" %}
When assembling a `.cl2` file, make sure that the file size stays the same. Its always 0x0440 bytes. 0x40 for the header and 0x0400 for the color data.
{% endhint %}

### Files

{% file src="<https://2200278744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsjAK0qgD0UbVIvvwnxgt%2Fuploads%2FAiDRbwmxydT9unSyctmJ%2Fequipment%20preview.cl2?alt=media&token=c2c0b0e1-7bf6-4712-bf10-59254e5421ba>" %}
