# Introduction

SpaceChop is the best way to do easy image processing. The tool is designed to help you quickly setup a service that fetches original images from your source and process and deliver them accordingly, and can be used with any back-end or front-end. The client is:

## Overview

![](https://1854019989-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL977gUetFxl6fTTYTB%2F-LNQHPqHXl-hw2nStgQW%2F-LNQHRIBCg0Vehol1Ivi%2Fsc-overview.png?generation=1538056112070121\&alt=media)

**Paths**\
A path is an URL pattern that will be accepted by SpaceChop. The pattern will consist of a set of parameters that will be extracted from the URL using [path-to-regex](https://github.com/pillarjs/path-to-regexp).

| Path              | URL                | Parameters                                |
| ----------------- | ------------------ | ----------------------------------------- |
| `/:preset/:image` | `/t_thumb/cat.jpg` | `{ preset: "t_thumb", image: "cat.jpg" }` |

**Parameters**\
The parameters extracted from the URL can be consumed other parts of SpaceChop when fetching, transforming and storing the original image. There is only one parameter that must be set in the path, and that is `preset`, which is used to determine which preset should be used.

**Sources**\
Sources defines how original images can be fetched. One type of source is the *HTTP Source* which will fetch the original via a standard GET request. We can configure the source like this:

{% code title="config.yml" %}

```yaml
sources:
  - http:
      root: https://example.com/assets/:image
```

{% endcode %}

You can see here that we used the parameter image to define the path from where original image should be fetched. So if the `image = 'cat.jpg'` the original image would be fetched from `https://example.com/assets/cat.jpg`

**Presets**\
A preset describe the series of operations that will be performed on the original image to create the final image.

A common preset is to create a small thumbnail of the original image to be used as a preview. We can define this preset as this:

{% code title="config.yml" %}

```yaml
presets:
  steps:
    - $crop:
        width: 200
        height: 200
    - $compress:
        quality: 75
```

{% endcode %}

This will result in a compressed 200x200px image.

**Storage**\
If a storage is defined the final image will be uploaded there after the transformation is completed. Subsequent requests for this image will be fetched from the storage instead of being transformed again.

A storage provider is the *S3 Storage* which will upload the image to your S3 bucket. The configuration looks like this (some configuration left out for brevity):

{% code title="config.yml" %}

```yaml
storage:
  s3:
    bucket_name: 'my-images'
    path: 'transformed/:preset/:image.:hash'
```

{% endcode %}

Again, we make use of parameters to describe where the transformation should be stored.


---

# 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://spacechop.gitbook.io/spacechop/master.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.
