# Production prep

> Takes what production needs from an image: its materials, colours or print, a larger copy, or a vector file.

## Tasks

- [Extract the materials of a garment](https://docs.refabric.com/task-api-reference/image.extract_materials) — `image.extract_materials`: Read the fabrics, trims and components a garment is made of from its image, each with a close-up, and the garment's colours. Delivered as one file with the findings in its data.
- [Extract the colours of a garment](https://docs.refabric.com/task-api-reference/image.extract_colours) — `image.extract_colours`: Read a garment's colours from its image, with their Pantone matches, largest share first. Delivered as a palette image with the colours in its data.
- [Extract the print of a garment](https://docs.refabric.com/task-api-reference/image.extract_print) — `image.extract_print`: Lift the print of a garment out of its image as a flat, reusable swatch. Delivered as one image file.
- [Upscale an image to 4K](https://docs.refabric.com/task-api-reference/image.upscale) — `image.upscale`: Enlarge an image to 4K (3840 px on its long edge) for print and zoom. An image that is already 4K comes back as it is. Delivered as one image file.
- [Convert a drawing to SVG](https://docs.refabric.com/task-api-reference/image.to_svg) — `image.to_svg`: Convert a technical drawing into a layered SVG vector file, ready for tech packs and cutting. Delivered as one SVG file.

## Quick start (`image.extract_materials`)

```python
import os
import time
import requests

headers = {"Authorization": f"Key {os.environ['REFABRIC_API_KEY']}"}

job = requests.post(
    "https://api.refabric.com/v1/tasks/image.extract_materials",
    headers=headers,
    json={
        "image": "art:9f3c01",
    },
).json()
print(job["job_id"])

while True:
    status = requests.get(job["status_url"], headers=headers).json()
    if status["lifecycle"] == "terminal":
        break
    time.sleep(5)

print(requests.get(job["result_url"], headers=headers).json())
```

```javascript
const headers = {
  Authorization: `Key ${process.env.REFABRIC_API_KEY}`,
  "Content-Type": "application/json",
};

const job = await fetch("https://api.refabric.com/v1/tasks/image.extract_materials", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "image": "art:9f3c01"
  }),
}).then((r) => r.json());
console.log(job.job_id);

let status = job;
while (status.lifecycle !== "terminal") {
  await new Promise((r) => setTimeout(r, 5000));
  status = await fetch(job.status_url, { headers }).then((r) => r.json());
}

console.log(await fetch(job.result_url, { headers }).then((r) => r.json()));
```

```bash
curl -X POST "https://api.refabric.com/v1/tasks/image.extract_materials" \
  -H "Authorization: Key $REFABRIC_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Prefer: wait=60" \
  -d '{"image":"art:9f3c01"}'
```
