# Image editing

> Changes one thing in an image you send — its background, frame, face, pose, fabric, views or finish — and keeps the rest.

## Tasks

- [Change a garment's texture](https://docs.refabric.com/task-api-reference/image.change_texture) — `image.change_texture`: Change the texture, print and colour of one garment in a finished image to match a fabric, keeping the person, the pose and the scene. Delivered as one image file.
- [Change an image's background](https://docs.refabric.com/task-api-reference/image.change_background) — `image.change_background`: Put a finished image on a new background — a backdrop from your library, a photo, a scene you describe, or none at all (a transparent PNG) — keeping everything in front of it as it is. Delivered as one image file.
- [Expand an image](https://docs.refabric.com/task-api-reference/image.expand) — `image.expand`: Grow a finished image outward by a number of pixels on each side, filling the new space with more of the same scene. Delivered as one image file.
- [Fix the face in an image](https://docs.refabric.com/task-api-reference/image.face_fix) — `image.face_fix`: Redo the face in a finished shoot image so it matches the model it was shot with, leaving the pose, the garment and the background as they are. Delivered as one image file.
- [Change one detail of an image](https://docs.refabric.com/task-api-reference/image.glam) — `image.glam`: Change one thing you name in a finished image — the lipstick, a button, an earring — and leave the rest untouched. Delivered as one image file.
- [Put a model in new poses](https://docs.refabric.com/task-api-reference/image.repose) — `image.repose`: Put the same person in the same clothes into new poses — picked from the pose library or described in words. Delivered as one image file per pose, in the order you listed them.
- [Turn an image into a sketch](https://docs.refabric.com/task-api-reference/image.to_sketch) — `image.to_sketch`: Turn a garment image into a technical drawing, in the style you choose, as line art or in colour. Delivered as one image file.
- [Rotate an image to its other views](https://docs.refabric.com/task-api-reference/image.rotate_views) — `image.rotate_views`: Turn the subject of an image around: its back, left and right views, keeping its medium and style. Delivered as up to three image files, in that order.
- [Polish shoot images](https://docs.refabric.com/task-api-reference/image.polish) — `image.polish`: Correct the light and colour of finished images of one of your shoots, keeping everything else. One polished file per image.

## Quick start (`image.change_texture`)

```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.change_texture",
    headers=headers,
    json={
        "image": "art:9f2c01",
        "fabric": "fabric:5f0c1d2e-8a41-4b7e-9c3d-1a2b3c4d5e60",
        "prompt": "the knit should be the ribbed cream one, not flat white",
    },
).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.change_texture", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "image": "art:9f2c01",
    "fabric": "fabric:5f0c1d2e-8a41-4b7e-9c3d-1a2b3c4d5e60",
    "prompt": "the knit should be the ribbed cream one, not flat white"
  }),
}).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.change_texture" \
  -H "Authorization: Key $REFABRIC_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Prefer: wait=60" \
  -d '{"image":"art:9f2c01","fabric":"fabric:5f0c1d2e-8a41-4b7e-9c3d-1a2b3c4d5e60","prompt":"the knit should be the ribbed cream one, not flat white"}'
```
