Skip to content

Commit 4f4c6c5

Browse files
committed
Version 4.0-rc docs
1 parent ea0edb8 commit 4f4c6c5

16 files changed

+506
-112
lines changed

docs/configuration/options.mdx

Lines changed: 106 additions & 42 deletions
Large diffs are not rendered by default.

docs/features/cache.mdx

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: Cache
3+
description: Learn about how to configure and use imgproxy's internal cache
4+
---
5+
6+
# Cache ((pro))
7+
8+
imgproxy Pro provides an internal cache that stores processed images on disk or in cloud storage. This cache can act as both a primary cache and a secondary cache that serves as a fallback when your CDN cache misses.
9+
10+
:::tip
11+
While putting a CDN in front of imgproxy is and will always be a best practice, the internal cache provides long-term storage for cases that require an additional caching layer.
12+
:::
13+
14+
## Why use internal cache?
15+
16+
The internal cache provides long-term persistent storage for processed images, unlike CDNs that typically delete rarely accessed content. It stores images in a single location rather than across multiple edge stores, eliminating cache misses when requests hit different edges. The cache is designed specifically for imgproxy, working seamlessly with features like modern image format detection and client hints support that generic external caches don't understand.
17+
18+
The cache is protected by the same security measures as imgproxy itself, including URL signatures and processing restrictions. Importantly, URL signatures are not part of the cache key, so you can rotate keys or use multiple key/salt pairs without invalidating cached images. You maintain full control over where the cache is stored and how it integrates with your infrastructure.
19+
20+
## Configuration
21+
22+
You need to define the following config variables to enable the internal cache:
23+
24+
* [`IMGPROXY_CACHE_USE`]: the cache storage adapter to use. Can be `filesystem`, `s3`, `gcs`, `abs` (Azure Blob Storage), or `swift`. When blank, the cache is disabled. Default: blank
25+
* [`IMGPROXY_CACHE_PATH_PREFIX`]: _(optional)_ a path prefix for the cache files. This can be useful to organize cache files in a specific directory structure. Default: blank
26+
* [`IMGPROXY_CACHE_BUCKET`]: _(optional)_ the bucket name for cloud storage adapters (S3, GCS, ABS, Swift). When using filesystem adapter, this can be used as an additional path component. Default: blank
27+
* [`IMGPROXY_CACHE_KEY_HEADERS`]: _(optional)_ a list of HTTP request headers (comma-separated) to include in the cache key. This allows caching different versions of the same image based on request headers. Default: blank
28+
* [`IMGPROXY_CACHE_KEY_COOKIES`]: _(optional)_ a list of HTTP request cookies (comma-separated) to include in the cache key. This allows caching different versions of the same image based on cookies. Default: blank
29+
* [`IMGPROXY_CACHE_REPORT_ERRORS`]: when `true`, imgproxy will report cache errors instead of silently falling back to processing without cache. Default: `false`
30+
31+
### Storage configuration
32+
33+
The internal cache supports all the storage backends that imgproxy can read source images from: local filesystem, Amazon S3 and compatible services (Cloudflare R2, DigitalOcean Spaces, MinIO, etc.), Google Cloud Storage, Microsoft Azure Blob Storage, and OpenStack Swift.
34+
35+
Configure the storage backend using the same configuration options as for image sources, but with the `IMGPROXY_CACHE_` prefix instead:
36+
37+
* For filesystem cache, use [`IMGPROXY_CACHE_LOCAL_FILESYSTEM_ROOT`](../configuration/options.mdx#cache-storage-local-filesystem)
38+
* For S3 cache, use `IMGPROXY_CACHE_S3_*` [variables](../configuration/options.mdx#cache-storage-amazon-s3) (e.g., `IMGPROXY_CACHE_S3_REGION`, `IMGPROXY_CACHE_S3_ENDPOINT`)
39+
* For GCS cache, use `IMGPROXY_CACHE_GCS_*` [variables](../configuration/options.mdx#cache-storage-google-cloud-storage)
40+
* For Azure Blob Storage cache, use `IMGPROXY_CACHE_ABS_*` [variables](../configuration/options.mdx#cache-storage-azure-blob-storage)
41+
* For Swift cache, use `IMGPROXY_CACHE_SWIFT_*` [variables](../configuration/options.mdx#cache-storage-openstack-swift)
42+
43+
See the [configuration options](../configuration/options.mdx#cache) documentation for the full list of available variables.
44+
45+
## Examples
46+
47+
### Filesystem cache
48+
49+
```bash
50+
IMGPROXY_CACHE_USE=filesystem
51+
IMGPROXY_CACHE_LOCAL_FILESYSTEM_ROOT=/var/cache/imgproxy
52+
IMGPROXY_CACHE_PATH_PREFIX=images
53+
```
54+
55+
### S3 cache
56+
57+
```bash
58+
IMGPROXY_CACHE_USE=s3
59+
IMGPROXY_CACHE_BUCKET=my-imgproxy-cache
60+
IMGPROXY_CACHE_S3_REGION=us-east-1
61+
# AWS credentials are provided via IAM role or environment variables
62+
```
63+
64+
### Google Cloud Storage cache
65+
66+
```bash
67+
IMGPROXY_CACHE_USE=gcs
68+
IMGPROXY_CACHE_BUCKET=my-imgproxy-cache
69+
IMGPROXY_CACHE_GCS_KEY=/path/to/credentials.json
70+
```
71+
72+
### Azure Blob Storage cache
73+
74+
```bash
75+
IMGPROXY_CACHE_USE=abs
76+
IMGPROXY_CACHE_BUCKET=imgproxy-cache
77+
IMGPROXY_CACHE_ABS_NAME=mystorageaccount
78+
IMGPROXY_CACHE_ABS_KEY=your_account_key
79+
```
80+
81+
## Cache key
82+
83+
The cache key is generated based on:
84+
85+
* Source image URL
86+
* Processing options
87+
* Output format
88+
* Optional: Request headers specified in `IMGPROXY_CACHE_KEY_HEADERS`
89+
* Optional: Request cookies specified in `IMGPROXY_CACHE_KEY_COOKIES`
90+
91+
URL signature is **not** a part of the cache key, which allows key rotation without invalidating the cache.
92+
93+
## Limitations
94+
95+
* **No manual cache invalidation**: Currently, imgproxy doesn't provide built-in means to invalidate the cache. However, imgproxy includes the [cachebuster](../usage/processing.mdx#cache-buster) in the cache key, so you can use it to force cache invalidation when needed. Most storage offerings also support object expiration, so you can set a reasonable expiration time for cached images.
96+
* **No cache for info requests**: The internal cache is currently only used for image processing requests. Requests to the `/info` endpoint are not cached.
97+
98+
## How it works
99+
100+
When a request comes in:
101+
102+
1. imgproxy checks the URL signature (if enabled)
103+
2. imgproxy generates the cache key from the request parameters
104+
3. imgproxy checks if a cached image exists in the configured storage
105+
4. If the cached image exists and is valid, imgproxy serves it directly
106+
5. If not, imgproxy processes the image and stores the result in the cache before serving it
107+
108+
## Monitoring
109+
110+
Monitor cache performance with metrics:
111+
112+
* Cache hit rate
113+
* Cache size
114+
* Cache evictions
115+
* Cache latency
116+
117+
These metrics are available through [monitoring endpoints](../monitoring/prometheus.mdx).
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Object classification
3+
description: Learn about how to classify objects in your images with imgproxy
4+
---
5+
6+
# Object classification ((pro))
7+
8+
imgproxy Pro can classify objects detected in images, providing detailed information about what the objects are. This feature extends [object detection](object_detection.mdx) by not only detecting objects but also identifying their specific classes or categories.
9+
10+
:::info
11+
Object classification requires [object detection](object_detection.mdx) to be configured and enabled. Classification is performed on the objects detected by the object detection model.
12+
:::
13+
14+
You can use object classification for content moderation, image organization, and automatic tagging. You can [fetch the classified objects info](../usage/getting_info.mdx#classify-objects) via the info handler.
15+
16+
## Configuration
17+
18+
:::tip
19+
If you're using an imgproxy Pro Docker image with a tag suffixed with `-ml`, a basic classification model is included. For advanced classification, you may want to configure your own model.
20+
:::
21+
22+
You need to define the following config variables to enable object classification:
23+
24+
* [`IMGPROXY_OBJECT_CLASSIFY_NET`]: a path to the classification neural network model in ONNX format
25+
* [`IMGPROXY_OBJECT_CLASSIFY_CLASSES`]: a path to the [class names file](#class-names-file)
26+
* [`IMGPROXY_OBJECT_CLASSIFY_NET_SIZE`]: the size of the neural network input. The width and the heights of the inputs should be the same, so this config value should be a single number. Default: 224
27+
* [`IMGPROXY_OBJECT_CLASSIFY_THRESHOLD`]: classifications with confidence below this value will be discarded. Default: 0.5
28+
* [`IMGPROXY_OBJECT_CLASSIFY_NORMALIZATION`]: the normalization type to apply to the input image. Possible values:
29+
* `none`: no normalization
30+
* `half`: normalize to [-0.5, 0.5] range
31+
* `full`: normalize to [-1, 1] range
32+
* `imagenet`: normalize using ImageNet mean and standard deviation
33+
34+
Default: `none`
35+
* [`IMGPROXY_OBJECT_CLASSIFY_LAYOUT`]: the data layout of the neural network input. Possible values:
36+
* `nchw`: channels first (default)
37+
* `nhwc`: channels last
38+
39+
Default: `nchw`
40+
41+
### Class names file
42+
43+
The class names file is used to map the class indexes from the neural network output to human-readable class names. The path to the class names file should be defined in the `IMGPROXY_OBJECT_CLASSIFY_CLASSES` config variable.
44+
45+
The class names file should contain one class name per line. The class names should be in the same order as the classes in the neural network output. Example:
46+
47+
```text
48+
person
49+
bicycle
50+
car
51+
```
52+
53+
## Getting classification info
54+
55+
Object classification is available via the info handler using the `co` (classify objects) endpoint. Fetch classification results by specifying the number of top classes to return:
56+
57+
```imgproxy_url
58+
.../info/co:5/...
59+
```
60+
61+
Where `5` is the number of top classes to return.
62+
63+
The response is an array of objects, each containing:
64+
65+
* `class_id`: The numeric ID of the class
66+
* `name`: The class name from the class names file
67+
* `confidence`: The confidence score for this classification
68+
69+
See [getting info documentation](../usage/getting_info.mdx#classify-objects) for more details.

docs/features/object_detection.mdx

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,16 @@ description: Learn about how to detect objects in your images and use them with
55

66
# Object detection ((pro))
77

8-
imgproxy can detect objects in the image and use them for smart cropping, blurring the detections, or drawing the detections. You can also [fetch the detected objects info](../usage/getting_info.mdx#detect-objects).
8+
imgproxy can detect objects in the image and use them for smart cropping, blurring the detections, drawing the detections, or cropping to detected objects. You can also [fetch the detected objects info](../usage/getting_info.mdx#detect-objects).
99

10-
For object purposes, imgproxy uses the YOLO (You Only Look Once) model family. imgproxy supports models in DarkNet or ONNX format. We provide Docker images with a model trained for face detection, but you can use any YOLO model found on the internet or train your own model.
10+
For object purposes, imgproxy uses the YOLO (You Only Look Once) model family. imgproxy supports models in ONNX format. We provide Docker images with a model trained for face detection, but you can use any YOLO model found on the internet or train your own model.
1111

1212
## Configuration
1313

1414
:::tip
1515
You don't need to configure object detection if you're using an imgproxy Pro Docker image with a tag suffixed with `-ml` and you want to use the face detection model. The model is already included in the image and the configuration is already set up.
1616
:::
1717

18-
:::info
19-
DarkNet model format has priority over ONNX model format. If you define both, imgproxy will use the DarkNet model.
20-
:::
21-
22-
### DarkNet model format
23-
24-
:::warning
25-
DarkNet models support is deprecated and will be removed in imgproxy v4. Please use ONNX models instead.
26-
:::
27-
28-
You need to define the following config variables to enable object detection with a [DarkNet](https://github.com/AlexeyAB/darknet) model:
29-
30-
* [`IMGPROXY_OBJECT_DETECTION_CONFIG`]: a path to the neural network config in DarkNet format
31-
* [`IMGPROXY_OBJECT_DETECTION_WEIGHTS`]: a path to the neural network weights in DarkNet format
32-
* [`IMGPROXY_OBJECT_DETECTION_CLASSES`]: a path to the [class names file](#class-names-file)
33-
34-
### ONNX model format
35-
3618
You need to define the following config variables to enable object detection with an ONNX model:
3719

3820
* [`IMGPROXY_OBJECT_DETECTION_NET`]: a path to the neural network model in ONNX format
@@ -336,6 +318,20 @@ You can make imgproxy [draw bounding boxes](../usage/processing.mdx#draw-detecti
336318
.../draw_detections:1:face/...
337319
```
338320

321+
### Crop to detected objects
322+
323+
You can make imgproxy [crop the image](../usage/processing.mdx#crop-objects) to fit all detected objects of the desired classes:
324+
325+
```imgproxy_url
326+
.../crop_objects:1.2:face:person/...
327+
```
328+
329+
This will automatically crop the image to include all detected faces and persons with 20% padding around them. You can omit class names to crop to all detected objects:
330+
331+
```imgproxy_url
332+
.../co:1.0/...
333+
```
334+
339335
### Fetch the detected objects' info
340336

341337
You can [fetch the detected objects info](../usage/getting_info.mdx#detect-objects) using the `/info` endpoint:

docs/image_formats_support.mdx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ At the moment, imgproxy supports only the most popular image formats:
2121
| TIFF | `tiff` | :white_check_mark: | :white_check_mark: |
2222
| PDF ((pro)) | `pdf` | :white_check_mark: | [See notes](#pdf-support) |
2323
| PSD ((pro)) | `psd` | [See notes](#psd-support) | :x: |
24+
| RAW ((pro)) | | [See notes](#raw-support) | :x: |
2425
| MP4 (h264) ((pro)) | `mp4` | [See notes](#video-thumbnails) | :white_check_mark: |
2526
| Other video formats ((pro)) | | [See notes](#video-thumbnails) | :x: |
2627

@@ -36,10 +37,6 @@ imgproxy supports SVG sources without limitations, but SVG results are not suppo
3637

3738
When the source image is SVG and an SVG result is requested, imgproxy returns the source image without modifications.
3839

39-
imgproxy reads some amount of bytes to check if the source image is SVG. By default it reads a maximum of 32KB, but you can change this:
40-
41-
* `IMGPROXY_MAX_SVG_CHECK_BYTES`: the maximum number of bytes imgproxy will read to recognize SVG. If imgproxy can't recognize your SVG, try to increase this number. Default: `32768` (32KB)
42-
4340
## Animated images support
4441

4542
Since the processing of animated images is a pretty heavy process, only one frame is processed by default. You can increase the maximum of animation frames to process with the following variable:
@@ -70,6 +67,12 @@ We tested imgproxy with all variants of PSD/PSB files that we could find or prod
7067
We couldn't find any PSD/PSB files with their image data compressed with ZIP, so imgproxy renders them as solid white images. If you had such files, we would very much appreciate it if you could share them with us.
7168
:::
7269

70+
## RAW support ((pro)) {#raw-support}
71+
72+
RAW image formats from digital cameras are supported as source images only (read-only). RAW files are decoded and converted to standard image formats during processing.
73+
74+
imgproxy uses [libraw](https://www.libraw.org/) to process RAW files. For a complete list of supported camera models and RAW formats, see the [libraw supported cameras list](https://www.libraw.org/supported-cameras).
75+
7376
## Converting animated images to MP4 ((pro)) {#converting-animated-images-to-mp4}
7477

7578
Animated image results can be converted to MP4 by specifying the `mp4` extension.
@@ -84,3 +87,22 @@ Since this still requires more data to be downloaded, video thumbnail generation
8487

8588
* `IMGPROXY_ENABLE_VIDEO_THUMBNAILS`: when true, enables video thumbnail generation. Default: `false`
8689
* `IMGPROXY_VIDEO_THUMBNAIL_SECOND`: the timestamp of the frame (in seconds) that will be used for the thumbnail. Default: `1`.
90+
91+
## Colorspace and HDR preservation
92+
93+
imgproxy always preserves the source image's colorspace:
94+
95+
* Color images remain color images
96+
* Grayscale images remain grayscale images
97+
* Colorspace types are maintained
98+
99+
The bit depth handling depends on the [IMGPROXY_PRESERVE_HDR](configuration/options.mdx#IMGPROXY_PRESERVE_HDR) configuration setting:
100+
101+
**When `IMGPROXY_PRESERVE_HDR` is enabled:**
102+
103+
* 16-bit images remain 16-bit in the output (eg. GRAYSCALE16 remains GRAYSCALE16, scRGB remains scRGB)
104+
105+
**When `IMGPROXY_PRESERVE_HDR` is disabled (default):**
106+
107+
* 16-bit images are converted to 8-bit (eg. GRAYSCALE16 becomes GRAYSCALE8, RGB and scRGB become sRGB)
108+
* 8-bit images remain 8-bit

docs/image_sources/amazon_s3.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ This allows imgproxy to access buckets in any region. However, the initial reque
7878
* If your most frequently used buckets are in the same region, set the region to that one.
7979
* If your buckets are spread across multiple regions, set the region to the closest one to your imgproxy instance.
8080

81+
## Restricting bucket access
82+
83+
For security purposes, you can restrict which S3 buckets imgproxy is allowed to access:
84+
85+
* `IMGPROXY_S3_ALLOWED_BUCKETS`: a comma-separated list of bucket names that imgproxy is allowed to access. When set, imgproxy will only process images from these buckets. Default: blank (all buckets allowed)
86+
* `IMGPROXY_S3_DENIED_BUCKETS`: a comma-separated list of bucket names that imgproxy is not allowed to access. When set, imgproxy will reject requests for images from these buckets. Default: blank
87+
88+
:::tip
89+
Use `IMGPROXY_S3_ALLOWED_BUCKETS` to create an allowlist of trusted buckets, or use `IMGPROXY_S3_DENIED_BUCKETS` to block specific buckets. If both are set, allowed buckets take precedence.
90+
:::
91+
8192
## MinIO
8293

8394
[MinIO](https://github.com/minio/minio) is an object storage server released under Apache License v2.0. It is compatible with Amazon S3, so it can be used with imgproxy.

docs/image_sources/azure_blob_storage.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,14 @@ For certificate authentication:
5050
### Using Storage Account Key
5151

5252
Alternatively, you can set `IMGPROXY_ABS_KEY` to your Azure Blob Storage account key. See the [Manage storage account access keys](https://learn.microsoft.com/en-us/azure/storage/common/storage-account-keys-manage) guide for more info.
53+
54+
## Restricting container access
55+
56+
For security purposes, you can restrict which Azure Blob Storage containers imgproxy is allowed to access:
57+
58+
* `IMGPROXY_ABS_ALLOWED_BUCKETS`: a comma-separated list of container names that imgproxy is allowed to access. When set, imgproxy will only process images from these containers. Default: blank (all containers allowed)
59+
* `IMGPROXY_ABS_DENIED_BUCKETS`: a comma-separated list of container names that imgproxy is not allowed to access. When set, imgproxy will reject requests for images from these containers. Default: blank
60+
61+
:::tip
62+
Use `IMGPROXY_ABS_ALLOWED_BUCKETS` to create an allowlist of trusted containers, or use `IMGPROXY_ABS_DENIED_BUCKETS` to block specific containers. If both are set, allowed containers take precedence.
63+
:::

docs/image_sources/google_cloud_storage.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,14 @@ Otherwise, set `IMGPROXY_GCS_KEY` environment variable to the content of Google
3636
:::warning
3737
For security reasons, imgproxy accepts only service account keys for Google Cloud Storage integration.
3838
:::
39+
40+
## Restricting bucket access
41+
42+
For security purposes, you can restrict which GCS buckets imgproxy is allowed to access:
43+
44+
* `IMGPROXY_GCS_ALLOWED_BUCKETS`: a comma-separated list of bucket names that imgproxy is allowed to access. When set, imgproxy will only process images from these buckets. Default: blank (all buckets allowed)
45+
* `IMGPROXY_GCS_DENIED_BUCKETS`: a comma-separated list of bucket names that imgproxy is not allowed to access. When set, imgproxy will reject requests for images from these buckets. Default: blank
46+
47+
:::tip
48+
Use `IMGPROXY_GCS_ALLOWED_BUCKETS` to create an allowlist of trusted buckets, or use `IMGPROXY_GCS_DENIED_BUCKETS` to block specific buckets. If both are set, allowed buckets take precedence.
49+
:::

0 commit comments

Comments
 (0)