-
-
Notifications
You must be signed in to change notification settings - Fork 8
Version 4.0-rc docs #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4f4c6c5
Version 4.0-rc docs
gzigzigzeo 7116b34
Cache docs
gzigzigzeo 839b176
Grammarly, fixed classification, addressed PR comments
gzigzigzeo 3d65af0
Various fixes, addressed PR comments
gzigzigzeo 69d0666
Minor updates by the comments
gzigzigzeo 2c66198
Version 4-preview
gzigzigzeo ad7bfb1
Correct banner in latest version
gzigzigzeo 7d18564
Update glibc version and distro list
gzigzigzeo 830ba1e
Update v4 autoquality docs
DarthSim b901370
Fix checking relative links with lychee
DarthSim 5440563
Remove `IMGPROXY_DOWNLOAD_BUFFER_SIZE` and `IMGPROXY_BUFFER_POOL_CALI…
DarthSim c285a95
Change v4-pre label and URL
DarthSim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| --- | ||
| title: Cache | ||
| description: Learn about how to configure and use imgproxy's internal cache | ||
| --- | ||
|
|
||
| # Cache ((pro)) | ||
|
|
||
| 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. | ||
|
|
||
| :::tip | ||
| 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. | ||
| ::: | ||
|
|
||
| ## Why use internal cache? | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| ## Configuration | ||
|
|
||
| You need to define the following config variables to enable the internal cache: | ||
|
|
||
| * [`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 | ||
| * [`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 | ||
| * [`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 | ||
| * [`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 | ||
| * [`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 | ||
| * [`IMGPROXY_CACHE_REPORT_ERRORS`]: when `true`, imgproxy will report cache errors instead of silently falling back to processing without cache. Default: `false` | ||
|
|
||
| ### Storage configuration | ||
|
|
||
| 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. | ||
|
|
||
| Configure the storage backend using the same configuration options as for image sources, but with the `IMGPROXY_CACHE_` prefix instead: | ||
|
|
||
| * For filesystem cache, use [`IMGPROXY_CACHE_LOCAL_FILESYSTEM_ROOT`](../configuration/options.mdx#cache-storage-local-filesystem) | ||
| * 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`) | ||
| * For GCS cache, use `IMGPROXY_CACHE_GCS_*` [variables](../configuration/options.mdx#cache-storage-google-cloud-storage) | ||
| * For Azure Blob Storage cache, use `IMGPROXY_CACHE_ABS_*` [variables](../configuration/options.mdx#cache-storage-azure-blob-storage) | ||
| * For Swift cache, use `IMGPROXY_CACHE_SWIFT_*` [variables](../configuration/options.mdx#cache-storage-openstack-swift) | ||
|
|
||
| See the [configuration options](../configuration/options.mdx#cache) documentation for the full list of available variables. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Filesystem cache | ||
|
|
||
| ```bash | ||
| IMGPROXY_CACHE_USE=filesystem | ||
| IMGPROXY_CACHE_LOCAL_FILESYSTEM_ROOT=/var/cache/imgproxy | ||
| IMGPROXY_CACHE_PATH_PREFIX=images | ||
| ``` | ||
|
|
||
| ### S3 cache | ||
|
|
||
| ```bash | ||
| IMGPROXY_CACHE_USE=s3 | ||
| IMGPROXY_CACHE_BUCKET=my-imgproxy-cache | ||
| IMGPROXY_CACHE_S3_REGION=us-east-1 | ||
| # AWS credentials are provided via IAM role or environment variables | ||
| ``` | ||
|
|
||
| ### Google Cloud Storage cache | ||
|
|
||
| ```bash | ||
| IMGPROXY_CACHE_USE=gcs | ||
| IMGPROXY_CACHE_BUCKET=my-imgproxy-cache | ||
| IMGPROXY_CACHE_GCS_KEY=/path/to/credentials.json | ||
| ``` | ||
|
|
||
| ### Azure Blob Storage cache | ||
|
|
||
| ```bash | ||
| IMGPROXY_CACHE_USE=abs | ||
| IMGPROXY_CACHE_BUCKET=imgproxy-cache | ||
| IMGPROXY_CACHE_ABS_NAME=mystorageaccount | ||
| IMGPROXY_CACHE_ABS_KEY=your_account_key | ||
| ``` | ||
|
|
||
| ## Cache key | ||
|
|
||
| The cache key is generated based on: | ||
|
|
||
| * Source image URL | ||
| * Processing options | ||
| * Output format | ||
| * Optional: Request headers specified in `IMGPROXY_CACHE_KEY_HEADERS` | ||
| * Optional: Request cookies specified in `IMGPROXY_CACHE_KEY_COOKIES` | ||
|
|
||
| URL signature is **not** a part of the cache key, which allows key rotation without invalidating the cache. | ||
|
|
||
| ## Limitations | ||
|
|
||
| * **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. | ||
| * **No cache for info requests**: The internal cache is currently only used for image processing requests. Requests to the `/info` endpoint are not cached. | ||
|
|
||
| ## How it works | ||
|
|
||
| When a request comes in: | ||
|
|
||
| 1. imgproxy checks the URL signature (if enabled) | ||
| 2. imgproxy generates the cache key from the request parameters | ||
| 3. imgproxy checks if a cached image exists in the configured storage | ||
| 4. If the cached image exists and is valid, imgproxy serves it directly | ||
| 5. If not, imgproxy processes the image and stores the result in the cache before serving it | ||
|
|
||
| ## Monitoring | ||
|
|
||
| Monitor cache performance with metrics: | ||
|
|
||
| * Cache hit rate | ||
| * Cache size | ||
| * Cache evictions | ||
| * Cache latency | ||
|
|
||
| These metrics are available through [monitoring endpoints](../monitoring/prometheus.mdx). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --- | ||
| title: Object classification | ||
| description: Learn about how to classify objects in your images with imgproxy | ||
| --- | ||
|
|
||
| # Object classification ((pro)) | ||
|
|
||
| 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. | ||
|
|
||
| :::info | ||
| 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. | ||
| ::: | ||
|
|
||
| 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. | ||
|
|
||
| ## Configuration | ||
|
|
||
| :::tip | ||
| 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. | ||
| ::: | ||
|
|
||
| You need to define the following config variables to enable object classification: | ||
|
|
||
| * [`IMGPROXY_OBJECT_CLASSIFY_NET`]: a path to the classification neural network model in ONNX format | ||
| * [`IMGPROXY_OBJECT_CLASSIFY_CLASSES`]: a path to the [class names file](#class-names-file) | ||
| * [`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 | ||
| * [`IMGPROXY_OBJECT_CLASSIFY_THRESHOLD`]: classifications with confidence below this value will be discarded. Default: 0.5 | ||
| * [`IMGPROXY_OBJECT_CLASSIFY_NORMALIZATION`]: the normalization type to apply to the input image. Possible values: | ||
| * `none`: no normalization | ||
| * `half`: normalize to [-0.5, 0.5] range | ||
gzigzigzeo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * `full`: normalize to [-1, 1] range | ||
| * `imagenet`: normalize using ImageNet mean and standard deviation | ||
|
|
||
| Default: `none` | ||
| * [`IMGPROXY_OBJECT_CLASSIFY_LAYOUT`]: the data layout of the neural network input. Possible values: | ||
| * `nchw`: channels first (default) | ||
| * `nhwc`: channels last | ||
gzigzigzeo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Default: `nchw` | ||
|
|
||
| ### Class names file | ||
|
|
||
| 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. | ||
|
|
||
| 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: | ||
|
|
||
| ```text | ||
| person | ||
| bicycle | ||
| car | ||
| ``` | ||
|
|
||
| ## Getting classification info | ||
|
|
||
| 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: | ||
|
|
||
| ```imgproxy_url | ||
| .../info/co:5/... | ||
gzigzigzeo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| Where `5` is the number of top classes to return. | ||
|
|
||
| The response is an array of objects, each containing: | ||
|
|
||
| * `class_id`: The numeric ID of the class | ||
| * `name`: The class name from the class names file | ||
| * `confidence`: The confidence score for this classification | ||
|
|
||
| See [getting info documentation](../usage/getting_info.mdx#classify-objects) for more details. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.