1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-24 08:12:38 +02:00

Docs/edits overhaul (#785)

* Update landing page / README.md

* Update GETTING_STARTED.md

* Update installation.md

* Update getting_the_image_info.md

* update signing_the_url.md

* Update watermark.md

* Update presets.md

* Update object_detection.md

* Update autoquality.md

* Update serving_local_files.md

* Update docs/serving_files_from_s3.md

* Update configuration.md

* Update generating_the_url.md

* Update chained_pipelines.md but chained pipelines section is not finished

* Update serving_files_from_google_cloud_storage.md

* Update new_relic.md

* Update prometheus.md

* Update datadog.md

* Update image_formats_support.md

* Update about_processing_pipeline.md

* Update healthcheck.md

* Update memory_usage_tweaks.md

* Remove GIF/ICO/BMP/HEIF/AVIF support sections from docs/image_formats_support.md

* Minor fixes of the docs

* Update serving_files_from_azure_blob_storage.md

* Fix issue with x and y offset for 're' watermark property

* Fix params description in docs/watermark.md

* Fix Alexander Madyankin GH name

* Special thanks to Travis

* Fix README

Co-authored-by: DarthSim <darthsim@gmail.com>
This commit is contained in:
Travis-Turner 2022-02-01 12:43:36 +03:00 committed by GitHub
parent 9a9756b111
commit c51521961f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 508 additions and 534 deletions

View File

@ -7,17 +7,13 @@
[![CircleCI branch](https://img.shields.io/circleci/project/github/imgproxy/imgproxy/master.svg?logo=circleci&style=for-the-badge)](https://circleci.com/gh/imgproxy/imgproxy) [![Docker](https://img.shields.io/badge/docker-darthsim%2Fimgproxy-blue.svg?logo=docker&logoColor=white&style=for-the-badge)](https://hub.docker.com/r/darthsim/imgproxy/) [![Docker Pulls](https://img.shields.io/docker/pulls/darthsim/imgproxy.svg?logo=docker&logoColor=white&style=for-the-badge)](https://hub.docker.com/r/darthsim/imgproxy/) [![Gitter](https://img.shields.io/gitter/room/imgproxy/imgproxy?logo=gitter&style=for-the-badge)](https://gitter.im/imgproxy/imgproxy) [![CircleCI branch](https://img.shields.io/circleci/project/github/imgproxy/imgproxy/master.svg?logo=circleci&style=for-the-badge)](https://circleci.com/gh/imgproxy/imgproxy) [![Docker](https://img.shields.io/badge/docker-darthsim%2Fimgproxy-blue.svg?logo=docker&logoColor=white&style=for-the-badge)](https://hub.docker.com/r/darthsim/imgproxy/) [![Docker Pulls](https://img.shields.io/docker/pulls/darthsim/imgproxy.svg?logo=docker&logoColor=white&style=for-the-badge)](https://hub.docker.com/r/darthsim/imgproxy/) [![Gitter](https://img.shields.io/gitter/room/imgproxy/imgproxy?logo=gitter&style=for-the-badge)](https://gitter.im/imgproxy/imgproxy)
imgproxy is a fast and secure standalone server for resizing and converting remote images. The main principles of imgproxy are simplicity, speed, and security. imgproxy is a fast and secure standalone server for resizing and converting remote images. The guiding principles behind imgproxy are security, speed, and simplicity.
imgproxy can be used to provide a fast and secure way to replace all the image resizing code of your web application (like calling ImageMagick or GraphicsMagick, or using libraries), while also being able to resize everything on the fly, fast and easy. imgproxy is also indispensable when handling lots of image resizing, especially when images come from a remote source. imgproxy is able to quickly and easily resize images on the fly, and it's well-equipped to handle a large amount of image resizing. imgproxy is a fast, secure replacement for all the image resizing code inside your web application (such as resizing libraries, or code that calls ImageMagick or GraphicsMagic). It's also an indispensable tool for processing images from a remote source. With imgproxy, you don’t need to repeatedly prepare images to fit your design every time it changes.
imgproxy does one thing — resizing remote images — and does it well. It works great when you need to resize multiple images on the fly to make them match your application design without preparing a ton of cached resized images or re-doing it every time the design changes. To get an even better introduction, and to dive deeper into the nitty gritty details, check out this article: [imgproxy: Resize your images instantly and securely](https://evilmartians.com/chronicles/introducing-imgproxy)
imgproxy is a Go application, ready to be installed and used in any Unix environment — also ready to be containerized using Docker. <a href="https://evilmartians.com/?utm_source=imgproxy" target="_blank">
See this article for a good intro and all the juicy details! [imgproxy: Resize your images instantly and securely](https://evilmartians.com/chronicles/introducing-imgproxy)
<a href="https://evilmartians.com/?utm_source=imgproxy">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians_v2.0.svg" alt="Sponsored by Evil Martians" width="236" height="54"> <img src="https://evilmartians.com/badges/sponsored-by-evil-martians_v2.0.svg" alt="Sponsored by Evil Martians" width="236" height="54">
</a> </a>
@ -27,27 +23,27 @@ See this article for a good intro and all the juicy details! [imgproxy: Resize y
imgproxy only includes the must-have features for image processing, fine-tuning and security. Specifically, imgproxy only includes the must-have features for image processing, fine-tuning and security. Specifically,
* It would be great to be able to rotate, flip and apply masks to images, but in most of the cases, it is possible — and is much easier — to do that using CSS3. * It would be great to be able to rotate, flip and apply masks to images, but in most of the cases, it is possible — and is much easier — to do that using CSS3.
* It may be great to have built-in HTTP caching of some kind, but it is way better to use a Content-Delivery Network or a caching proxy server for this, as you will have to do this sooner or later in the production environment. * It may be great to have built-in HTTP caching of some kind, but it is way better to use a Content-Delivery Network or a caching proxy server for this, as you will have to do this sooner or later in the production environment.
* It might be useful to have everything built in — such as HTTPS support — but an easy way to solve that would be just to use a proxying HTTP server such as nginx. * It might be useful to have everything built in — such as HTTPS support — but an easy way to solve that would be just to use a proxying HTTP server such as nginx.
#### Speed #### Speed
imgproxy uses probably the most efficient image processing library there is, called `libvips`. It is screaming fast and has a very low memory footprint; with it, we can handle the processing for a massive amount of images on the fly. imgproxy takes advantage of probably the most efficient image processing library out there – `libvips`. It’s scary fast and comes with a very low memory footprint. Thanks to libvips, we can readily and extemporaneously process a massive amount of images.
imgproxy also uses native Go's `net/http` routing for the best HTTP networking support. imgproxy uses Go’s raw (no wrappers) native `net/http` package to omit any overhead while processing requests and provides the best possible HTTP support.
You can see benchmarking results and comparison with some well-known alternatives in our [benchmark report](https://github.com/imgproxy/imgproxy/blob/master/BENCHMARK.md). You can take a look at some benchmarking results and compare imgproxy with some well-known alternatives in our [benchmark report](https://github.com/imgproxy/imgproxy/blob/master/BENCHMARK.md).
#### Security #### Security
Massive processing of remote images is a potentially dangerous thing, security-wise. There are many attack vectors, so it is a good idea to consider attack prevention measures first. Here is how imgproxy can help: In terms of security, the massive processing of remote images is a potentially dangerous endeavor. There are a number of possible attack vectors, so it’s a good idea to take an approach that considers attack prevention measures as a priority. Here’s how imgproxy does this:
* imgproxy checks image type _and_ "real" dimensions when downloading, so the image will not be fully downloaded if it has an unknown format or the dimensions are too big (there is a setting for that). That is how imgproxy protects you from so called "image bombs" like those described at https://www.bamsoftware.com/hacks/deflate.html. * imgproxy checks the image type and its “real” dimensions when downloading. The image will not be fully downloaded if it has an unknown format or if the dimensions are too big (you can set the max allowed dimensions). This is how imgproxy protects from so called "image bombs”, like those described in [this doc](https://www.bamsoftware.com/hacks/deflate.html).
* imgproxy protects image URLs with a signature, so an attacker cannot cause a denial-of-service attack by requesting multiple image resizes. * imgproxy protects image URLs with a signature, so an attacker cannot enact a denial-of-service attack by requesting multiple image resizes.
* imgproxy supports authorization by an HTTP header. That prevents using imgproxy directly by an attacker but allows to use it through a CDN or a caching server — just by adding a header to a proxy or CDN config. * imgproxy supports authorization by HTTP header. This prevents imgproxy from being used directly by an attacker, but allows it to be used via a CDN or a caching server — simply by adding a header to a proxy or CDN config.
## Usage ## Usage
@ -63,14 +59,15 @@ Many thanks to:
* [Roman Shamin](https://github.com/romashamin) for the awesome logo. * [Roman Shamin](https://github.com/romashamin) for the awesome logo.
* [Alena Kirdina](https://github.com/egodyston) and [Alexander Madyankin](https://github.com/madyankin) for the great website. * [Alena Kirdina](https://github.com/egodyston) and [Alexander Madyankin](https://github.com/madyankin) for the great website.
* [John Cupitt](https://github.com/jcupitt) who develops [libvips](https://github.com/libvips/libvips) and helps me to optimize its usage under the hood of imgproxy. * [John Cupitt](https://github.com/jcupitt) for developing [libvips](https://github.com/libvips/libvips) and for helping me optimize its usage with imgproxy.
* [Kirill Kuznetsov](https://github.com/dragonsmith) for the [Helm chart](https://github.com/imgproxy/imgproxy-helm). * [Kirill Kuznetsov](https://github.com/dragonsmith) for the [Helm chart](https://github.com/imgproxy/imgproxy-helm).
* [Travis Turner](https://github.com/Travis-Turner) for keeping the documentation in a good shape.
## License ## License
imgproxy is licensed under the MIT license. imgproxy is licensed under the MIT license.
See LICENSE for the full license text. See [LICENSE](https://github.com/imgproxy/imgproxy/blob/master/LICENSE) for the full license text.
## Security Contact ## Security Contact

View File

@ -1,10 +1,10 @@
# Getting started # Getting started
This guide will show you how to get your first image resized with imgproxy quickly. This guide will show you how to quickly resize your first image using imgproxy.
## Install ## Install
Let's assume you have Docker installed on your machine. Then you can pull an official imgproxy image, and you're done! Let's assume you already have Docker installed on your machine — you can pull an official imgproxy Docker image, and you’re done!
```bash ```bash
docker pull darthsim/imgproxy:latest docker pull darthsim/imgproxy:latest
@ -17,18 +17,18 @@ If you don't have docker, you can use Heroku for a quick start.
Check out our [installation guide](installation.md) for more details and instructions. Check out our [installation guide](installation.md) for more details and instructions.
That's it! No further configuration is needed, but if you want to unleash the full power of imgproxy, read our [configuration guide](configuration.md). In both cases, that's it! No further configuration is needed, but if you want to unleash the full power of imgproxy, read our [configuration guide](configuration.md).
## Resize an image ## Resize an image
After you've successfully installed imgproxy, you might want to see if it is working correctly. To check that, you can use the following URL to get the resized image of Matt Damon from "The Martian" movie (replace `localhost:8080` with your domain if you installed imgproxy on a remote server): After you’ve successfully installed imgproxy, a good first step is to make sure that everything is working correctly. To do that, you can use the following URL to get a resized image of Matt Damon from “The Martian” (replace `localhost:8080` with your domain if you’ve installed imgproxy on a remote server):
[http://localhost:8080/insecure/rs:fill:300:400/g:sm/aHR0cHM6Ly9tLm1l/ZGlhLWFtYXpvbi5j/b20vaW1hZ2VzL00v/TVY1Qk1tUTNabVk0/TnpZdFkyVm1ZaTAw/WkRSbUxUZ3lPREF0/WldZelpqaGxOemsx/TnpVMlhrRXlYa0Zx/Y0dkZVFYVnlOVGMz/TWpVek5USUAuanBn.jpg](http://localhost:8080/insecure/rs:fill:300:400/g:sm/aHR0cHM6Ly9tLm1l/ZGlhLWFtYXpvbi5j/b20vaW1hZ2VzL00v/TVY1Qk1tUTNabVk0/TnpZdFkyVm1ZaTAw/WkRSbUxUZ3lPREF0/WldZelpqaGxOemsx/TnpVMlhrRXlYa0Zx/Y0dkZVFYVnlOVGMz/TWpVek5USUAuanBn.jpg) [http://localhost:8080/insecure/rs:fill:300:400/g:sm/aHR0cHM6Ly9tLm1l/ZGlhLWFtYXpvbi5j/b20vaW1hZ2VzL00v/TVY1Qk1tUTNabVk0/TnpZdFkyVm1ZaTAw/WkRSbUxUZ3lPREF0/WldZelpqaGxOemsx/TnpVMlhrRXlYa0Zx/Y0dkZVFYVnlOVGMz/TWpVek5USUAuanBn.jpg](http://localhost:8080/insecure/rs:fill:300:400/g:sm/aHR0cHM6Ly9tLm1l/ZGlhLWFtYXpvbi5j/b20vaW1hZ2VzL00v/TVY1Qk1tUTNabVk0/TnpZdFkyVm1ZaTAw/WkRSbUxUZ3lPREF0/WldZelpqaGxOemsx/TnpVMlhrRXlYa0Zx/Y0dkZVFYVnlOVGMz/TWpVek5USUAuanBn.jpg)
Here's [the original image](https://m.media-amazon.com/images/M/MV5BMmQ3ZmY4NzYtY2VmYi00ZDRmLTgyODAtZWYzZjhlNzk1NzU2XkEyXkFqcGdeQXVyNTc3MjUzNTI@.jpg), just for reference. Using the URL above, imgproxy is told to resize it to fill the area of `300x400` size with "smart" gravity. "Smart" means that the `libvips` library chooses the most "interesting" part of the image. Just for reference, here’s [the original image](https://m.media-amazon.com/images/M/MV5BMmQ3ZmY4NzYtY2VmYi00ZDRmLTgyODAtZWYzZjhlNzk1NzU2XkEyXkFqcGdeQXVyNTc3MjUzNTI@.jpg). Using the URL above, imgproxy is instructed to resize it to fill an area of `300x400` size with “smart” gravity. “Smart” means that the `libvips` library chooses the most “interesting” part of the image.
Learn more on how to generate imgproxy URLs in the [Generating the URL](generating_the_url.md) guide. You can learn more on how to generate imgproxy URLs in the [Generating the URL](generating_the_url.md) guide.
## Security ## Security
Note that the URL in the above example is not signed. It is highly recommended to sign URLs in production. Read our [Signing the URL](signing_the_url.md) guide to know how to secure your imgproxy installation from attackers. Note that the URL in the above example is not signed. However, it’s highly recommended to use signed URLs in production. Read our [Signing the URL](signing_the_url.md) guide to learn how to secure your imgproxy installation from attackers.

View File

@ -1,15 +1,10 @@
# imgproxy # imgproxy
imgproxy is a fast and secure standalone server for resizing and converting remote images. The main principles of imgproxy are simplicity, speed, and security. imgproxy is a fast and secure standalone server for resizing and converting remote images. The guiding principles behind imgproxy are security, speed, and simplicity.
imgproxy can be used to provide a fast and secure way to replace all the image resizing code of your web application (like calling ImageMagick or GraphicsMagick, or using libraries), while also being able to resize everything on the fly, fast and easy. imgproxy is also indispensable when handling lots of image resizing, especially when images come from a remote source. imgproxy is able to quickly and easily resize images on the fly, and it's well-equipped to handle a large amount of image resizing. imgproxy is a fast, secure replacement for all the image resizing code inside your web application (such as resizing libraries, or code that calls ImageMagick or GraphicsMagic). It's also an indispensable tool for processing images from a remote source. With imgproxy, you don’t need to repeatedly prepare images to fit your design every time it changes.
imgproxy does one thing — resizing remote images — and does it well. It works great when you need to resize multiple images on the fly to make them match your application design without preparing a ton of cached resized images or re-doing it every time the design changes. To get an even better introduction, and to dive deeper into the nitty gritty details, check out this article: [imgproxy: Resize your images instantly and securely](https://evilmartians.com/chronicles/introducing-imgproxy)
imgproxy is a Go application, ready to be installed and used in any Unix environment — also ready to be containerized using Docker.
See this article for a good intro and all the juicy details! [imgproxy:
Resize your images instantly and securely](https://evilmartians.com/chronicles/introducing-imgproxy)
<a href="https://evilmartians.com/?utm_source=imgproxy" target="_blank"> <a href="https://evilmartians.com/?utm_source=imgproxy" target="_blank">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians_v2.0_for-dark-bg.svg" alt="Sponsored by Evil Martians" width="236" height="54"> <img src="https://evilmartians.com/badges/sponsored-by-evil-martians_v2.0_for-dark-bg.svg" alt="Sponsored by Evil Martians" width="236" height="54">
@ -21,27 +16,27 @@ Resize your images instantly and securely](https://evilmartians.com/chronicles/i
imgproxy only includes the must-have features for image processing, fine-tuning and security. Specifically, imgproxy only includes the must-have features for image processing, fine-tuning and security. Specifically,
* It would be great to be able to rotate, flip and apply masks to images, but in most of the cases, it is possible — and is much easier — to do that using CSS3. * It would be great to be able to rotate, flip and apply masks to images, but in most of the cases, it is possible — and is much easier — to do that using CSS3.
* It may be great to have built-in HTTP caching of some kind, but it is way better to use a Content-Delivery Network or a caching proxy server for this, as you will have to do this sooner or later in the production environment. * It may be great to have built-in HTTP caching of some kind, but it is way better to use a Content-Delivery Network or a caching proxy server for this, as you will have to do this sooner or later in the production environment.
* It might be useful to have everything built in — such as HTTPS support — but an easy way to solve that would be just to use a proxying HTTP server such as nginx. * It might be useful to have everything built in — such as HTTPS support — but an easy way to solve that would be just to use a proxying HTTP server such as nginx.
#### Speed #### Speed
imgproxy uses probably the most efficient image processing library there is, called `libvips`. It is screaming fast and has a very low memory footprint; with it, we can handle the processing for a massive amount of images on the fly. imgproxy takes advantage of probably the most efficient image processing library out there – `libvips`. It’s scary fast and comes with a very low memory footprint. Thanks to libvips, we can readily and extemporaneously process a massive amount of images.
imgproxy also uses native Go's `net/http` routing for the best HTTP networking support. imgproxy uses Go’s raw (no wrappers) native `net/http` package to omit any overhead while processing requests and provides the best possible HTTP support.
You can see benchmarking results and comparison with some well-known alternatives in our [benchmark report](https://github.com/imgproxy/imgproxy/blob/master/BENCHMARK.md). You can take a look at some benchmarking results and compare imgproxy with some well-known alternatives in our [benchmark report](https://github.com/imgproxy/imgproxy/blob/master/BENCHMARK.md).
#### Security #### Security
Massive processing of remote images is a potentially dangerous thing, security-wise. There are many attack vectors, so it is a good idea to consider attack prevention measures first. Here is how imgproxy can help: In terms of security, the massive processing of remote images is a potentially dangerous endeavor. There are a number of possible attack vectors, so it’s a good idea to take an approach that considers attack prevention measures as a priority. Here’s how imgproxy does this:
* imgproxy checks image type _and_ "real" dimensions when downloading, so the image will not be fully downloaded if it has an unknown format or the dimensions are too big (there is a setting for that). That is how imgproxy protects you from so called "image bombs" like those described at https://www.bamsoftware.com/hacks/deflate.html. * imgproxy checks the image type and its “real” dimensions when downloading. The image will not be fully downloaded if it has an unknown format or if the dimensions are too big (you can set the max allowed dimensions). This is how imgproxy protects from so called "image bombs”, like those described in [this doc](https://www.bamsoftware.com/hacks/deflate.html).
* imgproxy protects image URLs with a signature, so an attacker cannot cause a denial-of-service attack by requesting multiple image resizes. * imgproxy protects image URLs with a signature, so an attacker cannot enact a denial-of-service attack by requesting multiple image resizes.
* imgproxy supports authorization by an HTTP header. That prevents using imgproxy directly by an attacker but allows to use it through a CDN or a caching server — just by adding a header to a proxy or CDN config. * imgproxy supports authorization by HTTP header. This prevents imgproxy from being used directly by an attacker, but allows it to be used via a CDN or a caching server — simply by adding a header to a proxy or CDN config.
## Author ## Author
@ -52,9 +47,10 @@ Sergey "[DarthSim](https://github.com/DarthSim)" Alexandrovich
Many thanks to: Many thanks to:
* [Roman Shamin](https://github.com/romashamin) for the awesome logo. * [Roman Shamin](https://github.com/romashamin) for the awesome logo.
* [Alena Kirdina](https://github.com/egodyston) and [Alexander Madyankin](https://github.com/outpunk) for the great website. * [Alena Kirdina](https://github.com/egodyston) and [Alexander Madyankin](https://github.com/madyankin) for the great website.
* [John Cupitt](https://github.com/jcupitt) who develops [libvips](https://github.com/libvips/libvips) and helps me to optimize its usage under the hood of imgproxy. * [John Cupitt](https://github.com/jcupitt) for developing [libvips](https://github.com/libvips/libvips) and for helping me optimize its usage with imgproxy.
* [Kirill Kuznetsov](https://github.com/dragonsmith) for the [Helm chart](https://github.com/imgproxy/imgproxy-helm). * [Kirill Kuznetsov](https://github.com/dragonsmith) for the [Helm chart](https://github.com/imgproxy/imgproxy-helm).
* [Travis Turner](https://github.com/Travis-Turner) for keeping the documentation in a good shape.
## License ## License

View File

@ -2,15 +2,15 @@
imgproxy has a specific processing pipeline tuned for maximum performance. When you process an image with imgproxy, it does the following: imgproxy has a specific processing pipeline tuned for maximum performance. When you process an image with imgproxy, it does the following:
* If the source image format allows shrink-on-load, imgproxy uses it to quickly resize the image to the size that is closest to desired; * If the source image format allows shrink-on-load, imgproxy uses it to quickly resize the image to the size that is closest to desired.
* If it is needed to resize an image with an alpha-channel, imgproxy premultiplies one to handle alpha correctly; * If it is needed to resize an image with an alpha-channel, imgproxy premultiplies one to handle alpha correctly.
* imgproxy resizes the image to the desired size; * imgproxy resizes the image to the desired size.
* If the image colorspace need to be fixed, imgproxy fixes it; * If the image colorspace need to be fixed, imgproxy fixes it.
* imgproxy rotates/flip the image according to EXIF metadata; * imgproxy rotates/flip the image according to EXIF metadata.
* imgproxy crops the image using specified gravity; * imgproxy crops the image using the specified gravity.
* imgproxy fills the image background if the background color was specified; * imgproxy fills the image background if the background color was specified.
* imgproxy applies gaussian blur and sharpen filters; * imgproxy applies gaussian blur and sharpen filters.
* imgproxy adds watermark if one was specified; * imgproxy adds a watermark if one was specified.
* And finally, imgproxy saves the image to the desired format. * And finally, imgproxy saves the image to the desired format.
This pipeline with using sequential access to source image data allows to significantly reduce memory and CPU usage — one of the reasons imgproxy is so performant. This pipeline, using sequential access to source image data, allows for significantly reduced memory and CPU usage — one of the reasons imgproxy is so performant.

View File

@ -1,10 +1,10 @@
# Autoquality<i class='badge badge-pro'></i><i class='badge badge-v3'></i> # Autoquality<i class='badge badge-pro'></i><i class='badge badge-v3'></i>
imgproxy can calculate quality for your resulting images so they fit the selected metric the best. The supported methods are [none](#none), [size](#autoquality-by-file-size), [dssim](#autoquality-by-dssim), and [ml](#autoquality-with-ml). imgproxy can calculate quality for your resultant images so they best fit the selected metric. The supported methods are [none](#none), [size](#autoquality-by-file-size), [dssim](#autoquality-by-dssim), and [ml](#autoquality-with-ml).
**⚠️Warning:** Autoquality requires the image to be saved several times. Use it only when you prefer the resulting size and quality over the speed. **⚠️Warning:** Autoquality requires an image to be saved several times. Use it only when you prefer the resultant quality and size over speed.
You can enable autoquality with [config](configuration.md#autoquality) (for all images) or with [processing options](generating_the_url.md#autoquality) (for each image individually). You can enable autoquality using [config options](configuration.md#autoquality) (for all images) or with [processing options](generating_the_url.md#autoquality) (for each image individually).
## None ## None
@ -26,11 +26,11 @@ IMGPROXY_AUTOQUALITY_METHOD="none"
## Autoquality by file size ## Autoquality by file size
With this method, imgproxy will try to degrade the quality so your image fit the desired file size. With this method, imgproxy will try to degrade the quality so your image fits the desired file size.
**Method name:** `size` **Method name:** `size`
**Target:** desired file size **Target:** the desired file size
#### Config example #### Config example
@ -52,11 +52,11 @@ IMGPROXY_AUTOQUALITY_FORMAT_MAX="avif=50"
## Autoquality by DSSIM ## Autoquality by DSSIM
With this method imgproxy will try to select the quality so the saved image would have the desired [DSSIM](https://en.wikipedia.org/wiki/Structural_similarity#Structural_Dissimilarity) value. With this method imgproxy will try to select a level of quality so that the saved image will have the desired [DSSIM](https://en.wikipedia.org/wiki/Structural_similarity#Structural_Dissimilarity) value.
**Method name:** `dssim` **Method name:** `dssim`
**Target:** desired DSSIM value **Target:** the desired DSSIM value
#### Config example #### Config example
@ -81,13 +81,13 @@ IMGPROXY_AUTOQUALITY_FORMAT_MAX="avif=50"
## Autoquality with ML ## Autoquality with ML
This method is almost the same as [DSSIM](#autoquality-by-dssim) but imgproxy will try to predict the initial quality using neural networks. Requires neural networs to be configured (see the config examlpe or the config documentation). If a neural network for the resulting format is not provided, [DSSIM](#autoquality-by-dssim) method will be used instead. This method is almost the same as autoquality with [DSSIM](#autoquality-by-dssim) but imgproxy will try to predict the initial quality using neural networks. This requires neural networks to be configured (see the config examlpe or the config documentation). If a neural network for the resulting format is not provided, the [DSSIM](#autoquality-by-dssim) method will be used instead.
**📝Note:** When this method is used, imgproxy will save JPEG images with the most optimal [advanced JPEG compression](configuration.md#advanced-jpeg-compression) settings ignoring config and processing options. **📝Note:** When this method is used, imgproxy will save JPEG images with the most optimal [advanced JPEG compression](configuration.md#advanced-jpeg-compression) settings, ignoring config and processing options.
**Method name:** `ml` **Method name:** `ml`
**Target:** desired DSSIM value **Target:** the desired DSSIM value
#### Config example #### Config example
@ -108,7 +108,7 @@ IMGPROXY_AUTOQUALITY_WEBP_NET="/networks/autoquality-webp.pb"
IMGPROXY_AUTOQUALITY_AVIF_NET="/networks/autoquality-avif.pb" IMGPROXY_AUTOQUALITY_AVIF_NET="/networks/autoquality-avif.pb"
``` ```
**📝Note:** If you trust your autoquality neural network, you may want to set `IMGPROXY_AUTOQUALITY_ALLOWED_ERROR` to 1 (maximum possible DSSIM value). In this case, imgproxy will always use the quality predicted by the neural network. **📝Note:** If you trust your neural network's autoquality, you may want to set `IMGPROXY_AUTOQUALITY_ALLOWED_ERROR` to 1 (the maximum possible DSSIM value). In this case, imgproxy will always use the quality predicted by the neural network.
#### Processing options example #### Processing options example
@ -118,10 +118,10 @@ IMGPROXY_AUTOQUALITY_AVIF_NET="/networks/autoquality-avif.pb"
### Neural networks format ### Neural networks format
Neural networs should fit the following requirements: Neural networks should fit the following requirements:
* Tensorflow frozen graph format. * Tensorflow frozen graph format
* Input layer size is 416x416. * Input layer size is 416x416
* Output layer size is 1x100 * Output layer size is 1x100
* Output layer values are logits of quality probabilities. * Output layer values are logits of quality probabilities
If you're an imgproxy Pro user and you want to train your own network but you don't know how, feel free to contact the imgproxy team for intructions. If you're an imgproxy Pro user and you want to train your own network but you don't know how, feel free to contact the imgproxy team for instructions.

View File

@ -21,7 +21,7 @@ In this example, the first pipeline resizes the image and places the first water
### Example 2: Fast trim ### Example 2: Fast trim
The `trim` operation is pretty heavy as it involves loading the whole image to the memory at the very start of processing. However, if you're going to scale down your image and the trim accuracy is not very important to you, it's better to move trimming to a separate pipeline. Performing the `trim` operation is pretty heavy as it involves loading the entire image into memory from the very start of processing. However, if you're going to scale down your image and trim accuracy is not very important to you, it's better to move trimming to a separate pipeline.
``` ```
.../rs:fit:500:500/-/trim:10/... .../rs:fit:500:500/-/trim:10/...
@ -33,19 +33,19 @@ In this example, the first pipeline resizes the image, and the second pipeline t
You can use presets in your chained pipelines, and you can use chained pipelines in your presets. However, the behaior may be not obvious. The rules are the following: You can use presets in your chained pipelines, and you can use chained pipelines in your presets. However, the behaior may be not obvious. The rules are the following:
* Prest is applied to the pipeline where is was used. * A preset is applied to the pipeline where is was used.
* Preset may contain chained pipelined, and ones will be chained to the pipeline where the preset was used. * A preset may contain a chained pipeline, and will be chained to the pipeline where the preset was used.
* Chained pipelines from the preset and from the URL are merged. * Chained pipelines from the preset and from the URL are merged.
### Example ### Example
If we have the following preset If we have the following preset:
``` ```
test=width:300/height:300/-/width:200/height:200/-/width:100/height:200 test=width:300/height:300/-/width:200/height:200/-/width:100/height:200
``` ```
and the following URL And the following URL:
``` ```
.../width:400/-/preset:test/width:500/-/width:600/... .../width:400/-/preset:test/width:500/-/width:600/...

View File

@ -4,21 +4,21 @@ imgproxy is [Twelve-Factor-App](https://12factor.net/)-ready and can be configur
## URL signature ## URL signature
imgproxy allows URLs to be signed with a key and salt. This feature is disabled by default, but it is _highly_ recommended to enable it in production. To enable URL signature checking, define the key/salt pair: imgproxy allows URLs to be signed with a key and a salt. This feature is disabled by default, but is _highly_ recommended to be enabled in production. To enable URL signature checking, define the key/salt pair:
* `IMGPROXY_KEY`: hex-encoded key; * `IMGPROXY_KEY`: hex-encoded key
* `IMGPROXY_SALT`: hex-encoded salt; * `IMGPROXY_SALT`: hex-encoded salt
* `IMGPROXY_SIGNATURE_SIZE`: number of bytes to use for signature before encoding to Base64. Default: 32; * `IMGPROXY_SIGNATURE_SIZE`: number of bytes to use for signature before encoding to Base64. Default: 32
You can specify multiple key/salt pairs by dividing keys and salts with comma (`,`). imgproxy will check URL signatures with each pair. Useful when you need to change key/salt pair in your application with zero downtime. You can specify multiple key/salt pairs by dividing the keys and salts with a comma (`,`). imgproxy will check URL signatures with each pair. This is useful when you need to change key/salt pairs in your application while incurring zero downtime.
You can also specify paths to files with a hex-encoded keys and salts, one by line (useful in a development environment): You can also specify file paths using the command line by referencing a separate file containing hex-coded keys and salts line by line:
```bash ```bash
imgproxy -keypath /path/to/file/with/key -saltpath /path/to/file/with/salt imgproxy -keypath /path/to/file/with/key -saltpath /path/to/file/with/salt
``` ```
If you need a random key/salt pair real fast, you can quickly generate it using, for example, the following snippet: If you need a random key/salt pair really fast, as an example, you can quickly generate one using the following snippet:
```bash ```bash
echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n') echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
@ -26,119 +26,122 @@ echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
## Server ## Server
* `IMGPROXY_BIND`: address and port or Unix socket to listen on. Default: `:8080`; * `IMGPROXY_BIND`: the address and port or Unix socket to listen to. Default: `:8080`
* `IMGPROXY_NETWORK`: network to use. Known networks are `tcp`, `tcp4`, `tcp6`, `unix`, and `unixpacket`. Default: `tcp`; * `IMGPROXY_NETWORK`: the network to use. Known networks are `tcp`, `tcp4`, `tcp6`, `unix`, and `unixpacket`. Default: `tcp`
* `IMGPROXY_READ_TIMEOUT`: the maximum duration (in seconds) for reading the entire image request, including the body. Default: `10`; * `IMGPROXY_READ_TIMEOUT`: the maximum duration (in seconds) for reading the entire image request, including the body. Default: `10`
* `IMGPROXY_WRITE_TIMEOUT`: the maximum duration (in seconds) for writing the response. Default: `10`; * `IMGPROXY_WRITE_TIMEOUT`: the maximum duration (in seconds) for writing the response. Default: `10`
* `IMGPROXY_KEEP_ALIVE_TIMEOUT`: the maximum duration (in seconds) to wait for the next request before closing the connection. When set to `0`, keep-alive is disabled. Default: `10`; * `IMGPROXY_KEEP_ALIVE_TIMEOUT`: the maximum duration (in seconds) to wait for the next request before closing the connection. When set to `0`, keep-alive is disabled. Default: `10`
* `IMGPROXY_DOWNLOAD_TIMEOUT`: the maximum duration (in seconds) for downloading the source image. Default: `5`; * `IMGPROXY_DOWNLOAD_TIMEOUT`: the maximum duration (in seconds) for downloading the source image. Default: `5`
* `IMGPROXY_CONCURRENCY`: the maximum number of image requests to be processed simultaneously. Default: number of CPU cores times two; * `IMGPROXY_CONCURRENCY`: the maximum number of image requests to be processed simultaneously. Default: the number of CPU cores multiplied by two
* `IMGPROXY_MAX_CLIENTS`: the maximum number of simultaneous active connections. Default: `IMGPROXY_CONCURRENCY * 10`; * `IMGPROXY_MAX_CLIENTS`: the maximum number of simultaneous active connections. Default: `IMGPROXY_CONCURRENCY * 10`
* `IMGPROXY_TTL`: duration (in seconds) sent in `Expires` and `Cache-Control: max-age` HTTP headers. Default: `3600` (1 hour); * `IMGPROXY_TTL`: a duration (in seconds) sent via the `Expires` and `Cache-Control: max-age` HTTP headers. Default: `3600` (1 hour)
* `IMGPROXY_CACHE_CONTROL_PASSTHROUGH`: when `true` and source image response contains `Expires` or `Cache-Control` headers, reuse those headers. Default: false; * `IMGPROXY_CACHE_CONTROL_PASSTHROUGH`: when `true` and the source image response contains the `Expires` or `Cache-Control` headers, reuse those headers. Default: false
* `IMGPROXY_SET_CANONICAL_HEADER`: when `true` and the source image has `http` or `https` scheme, set `rel="canonical"` HTTP header to the value of the source image URL. More details [here](https://developers.google.com/search/docs/advanced/crawling/consolidate-duplicate-urls#rel-canonical-header-method). Default: false; * `IMGPROXY_SET_CANONICAL_HEADER`: when `true` and the source image has an `http` or `https` scheme, set a `rel="canonical"` HTTP header to the value of the source image URL. More details [here](https://developers.google.com/search/docs/advanced/crawling/consolidate-duplicate-urls#rel-canonical-header-method). Default: `false`
* `IMGPROXY_SO_REUSEPORT`: when `true`, enables `SO_REUSEPORT` socket option (currently on linux and darwin only); * `IMGPROXY_SO_REUSEPORT`: when `true`, enables `SO_REUSEPORT` socket option (currently only available on Linux and macOS);
* `IMGPROXY_PATH_PREFIX`: URL path prefix. Example: when set to `/abc/def`, imgproxy URL will be `/abc/def/%signature/%processing_options/%source_url`. Default: blank. * `IMGPROXY_PATH_PREFIX`: the URL path prefix. Example: when set to `/abc/def`, the imgproxy URL will be `/abc/def/%signature/%processing_options/%source_url`. Default: blank
* `IMGPROXY_USER_AGENT`: User-Agent header that will be sent with source image request. Default: `imgproxy/%current_version`; * `IMGPROXY_USER_AGENT`: the User-Agent header that will be sent with the source image request. Default: `imgproxy/%current_version`
* `IMGPROXY_USE_ETAG`: when `true`, enables using [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) HTTP header for HTTP cache control. Default: false; * `IMGPROXY_USE_ETAG`: when set to `true`, enables using the [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) HTTP header for HTTP cache control. Default: `false`
* `IMGPROXY_ETAG_BUSTER`: change this to change ETags for all the images. Default: blank. * `IMGPROXY_ETAG_BUSTER`: change this to change ETags for all the images. Default: blank
* `IMGPROXY_CUSTOM_REQUEST_HEADERS`: <i class='badge badge-pro'></i> list of custom headers that imgproxy will send while requesting the source image, divided by `\;` (can be redefined by `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`). Example: `X-MyHeader1=Lorem\;X-MyHeader2=Ipsum`; * `IMGPROXY_CUSTOM_REQUEST_HEADERS`: <i class='badge badge-pro'></i> list of custom headers that imgproxy will send while requesting the source image, divided by `\;` (can be redefined by `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`). Example: `X-MyHeader1=Lorem\;X-MyHeader2=Ipsum`
* `IMGPROXY_CUSTOM_RESPONSE_HEADERS`: <i class='badge badge-pro'></i> list of custom response headers, divided by `\;` (can be redefined by `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`). Example: `X-MyHeader1=Lorem\;X-MyHeader2=Ipsum`; * `IMGPROXY_CUSTOM_RESPONSE_HEADERS`: <i class='badge badge-pro'></i> a list of custom response headers, separated by `\;` (can be redefined by `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`). Example: `X-MyHeader1=Lorem\;X-MyHeader2=Ipsum`
* `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`: <i class='badge badge-pro'></i> string that will be used as a custom headers separator. Default: `\;`; * `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`: <i class='badge badge-pro'></i> a string that will be used as a custom header separator. Default: `\;`
* `IMGPROXY_ENABLE_DEBUG_HEADERS`: when `true`, imgproxy will add debug headers to the response. Default: `false`. The following headers will be added: * `IMGPROXY_ENABLE_DEBUG_HEADERS`: when set to `true`, imgproxy will add debug headers to the response. Default: `false`. The following headers will be added:
* `X-Origin-Content-Length`: size of the source image. * `X-Origin-Content-Length`: the size of the source image
* `X-Origin-Width`: width of the source image. * `X-Origin-Width`: the width of the source image
* `X-Origin-Height`: height of the source image. * `X-Origin-Height`: the height of the source image
## Security ## Security
imgproxy protects you from so-called image bombs. Here is how you can specify maximum image resolution which you consider reasonable: imgproxy protects you from so-called image bombs. Here's how you can specify the maximum image resolution which you consider reasonable:
* `IMGPROXY_MAX_SRC_RESOLUTION`: the maximum resolution of the source image, in megapixels. Images with larger actual size will be rejected. Default: `16.8`; * `IMGPROXY_MAX_SRC_RESOLUTION`: the maximum resolution of the source image, in megapixels. Images with larger actual size will be rejected. Default: `16.8`
* `IMGPROXY_MAX_SRC_FILE_SIZE`: the maximum size of the source image, in bytes. Images with larger file size will be rejected. When `0`, file size check is disabled. Default: `0`; * `IMGPROXY_MAX_SRC_FILE_SIZE`: the maximum size of the source image, in bytes. Images with larger file size will be rejected. When set to `0`, file size check is disabled. Default: `0`
imgproxy can process animated images (GIF, WebP), but since this operation is pretty heavy, only one frame is processed by default. You can increase the maximum of animation frames to process with the following variable: imgproxy can process animated images (GIF, WebP), but since this operation is pretty memory heavy, only one frame is processed by default. You can increase the maximum animation frames that can be processed number of with the following variable:
* `IMGPROXY_MAX_ANIMATION_FRAMES`: the maximum of animated image frames to being processed. Default: `1`. * `IMGPROXY_MAX_ANIMATION_FRAMES`: the maximum number of animated image frames that may be processed. Default: `1`
**📝Note:** imgproxy summarizes all frames resolutions while checking source image resolution. **📝Note:** imgproxy summarizes all frame resolutions while checking the source image resolution.
imgproxy reads some amount of bytes to check if the source image is SVG. By default it reads maximum of 32KB, but you can change this: To check if the source image is SVG, imgproxy reads some amount of bytes; by default it reads a maximum of 32KB. However, you can change this value using the following variable:
* `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) * `IMGPROXY_MAX_SVG_CHECK_BYTES`: the maximum number of bytes imgproxy will read to recognize SVG files. If imgproxy is unable to recognize your SVG, try increasing this number. Default: `32768` (32KB)
You can also specify a secret to enable authorization with the HTTP `Authorization` header for use in production environments: You can also specify a secret key to enable authorization with the HTTP `Authorization` header for use in production environments:
* `IMGPROXY_SECRET`: the authorization token. If specified, the HTTP request should contain the `Authorization: Bearer %secret%` header; * `IMGPROXY_SECRET`: the authorization token. If specified, the HTTP request should contain the `Authorization: Bearer %secret%` header.
imgproxy does not send CORS headers by default. Specify allowed origin to enable CORS headers: imgproxy does not send CORS headers by default. CORS will need to be allowed by uisng the following variable:
* `IMGPROXY_ALLOW_ORIGIN`: when set, enables CORS headers with provided origin. CORS headers are disabled by default. * `IMGPROXY_ALLOW_ORIGIN`: when specified, enables CORS headers with the provided origin. CORS headers are disabled by default.
You can limit allowed source URLs: You can limit allowed source URLs with the following variable:
* `IMGPROXY_ALLOWED_SOURCES`: whitelist of source image URLs prefixes divided by comma. Wildcards can be included with `*` to match all characters except `/`. When blank, imgproxy allows all source image URLs. Example: `s3://,https://*.example.com/,local://`. Default: blank. * `IMGPROXY_ALLOWED_SOURCES`: a whitelist of source image URL prefixes divided by comma. Wildcards can be included with `*` to match all characters except `/`. When blank, imgproxy allows all source image URLs. Example: `s3://,https://*.example.com/,local://`. Default: blank
**⚠️Warning:** Be careful when using this config to limit source URL hosts, and always add a trailing slash after the host. Bad: `http://example.com`, good: `http://example.com/`. If you don't add a trailing slash, `http://example.com@baddomain.com` will be an allowed URL but the request will be made to `baddomain.com`. **⚠️Warning:** Be careful when using this config to limit source URL hosts, and always add a trailing slash after the host.
* Bad: `http://example.com`
* Good: `http://example.com/`
If the trailing slash is absent, `http://example.com@baddomain.com` would be a permissable URL, however, the request would be made to `baddomain.com`.
When you use imgproxy in a development environment, it can be useful to ignore SSL verification: When using imgproxy in a development environment, it can be useful to ignore SSL verification:
* `IMGPROXY_IGNORE_SSL_VERIFICATION`: when true, disables SSL verification, so imgproxy can be used in a development environment with self-signed SSL certificates. * `IMGPROXY_IGNORE_SSL_VERIFICATION`: when true, disables SSL verification, so imgproxy can be used in a development environment with self-signed SSL certificates.
Also you may want imgproxy to respond with the same error message that it writes to the log: Also you may want imgproxy to respond with the same error message that it writes to the log:
* `IMGPROXY_DEVELOPMENT_ERRORS_MODE`: when true, imgproxy will respond with detailed error messages. Not recommended for production because some errors may contain stack trace. * `IMGPROXY_DEVELOPMENT_ERRORS_MODE`: when true, imgproxy will respond with detailed error messages. Not recommended for production because some errors may contain stack traces.
## Cookies ## Cookies
imgproxy can pass through cookies in image requests. This can be activated with `IMGPROXY_COOKIE_PASSTHROUGH`. Unfortunately a `Cookie` header doesn't contain information for which URLs these cookies are applicable, so imgproxy can only assume (or must be told). imgproxy can pass cookies in image requests. This can be activated with `IMGPROXY_COOKIE_PASSTHROUGH`. Unfortunately the `Cookie` header doesn't contain information about which URLs these cookies are applicable to, so imgproxy can only assume (or must be told).
When cookie forwarding is activated, imgproxy by default assumes the scope of the cookies to be all URLs with the same hostname/port and request scheme as given by the headers `X-Forwarded-Host`, `X-Forwarded-Port`, `X-Forwarded-Scheme` or `Host`. To change that use `IMGPROXY_COOKIE_BASE_URL`. When cookie forwarding is activated, by default, imgproxy assumes the scope of the cookies to be all URLs with the same hostname/port and request scheme as given by the headers `X-Forwarded-Host`, `X-Forwarded-Port`, `X-Forwarded-Scheme` or `Host`. To change that use `IMGPROXY_COOKIE_BASE_URL`.
* `IMGPROXY_COOKIE_PASSTHROUGH`: when `true`, incoming cookies will be passed through to the image request if they are applicable for the image URL. Default: false; * `IMGPROXY_COOKIE_PASSTHROUGH`: when `true`, incoming cookies will be passed through the image request if they are applicable for the image URL. Default: `false`
* `IMGPROXY_COOKIE_BASE_URL`: when set, assume that cookies have a scope of this URL for the incoming request (instead of using the request headers). If the cookies are applicable to the image URL too, they will be passed along in the image request. * `IMGPROXY_COOKIE_BASE_URL`: when set, assume that cookies have the scope of this URL for an incoming request (instead of using request headers). If the cookies are applicable to the image URL too, they will be passed along in the image request.
## Compression ## Compression
* `IMGPROXY_QUALITY`: default quality of the resulting image, percentage. Default: `80`; * `IMGPROXY_QUALITY`: the default quality of the resultant image, percentage. Default: `80`
* `IMGPROXY_FORMAT_QUALITY`: default quality of the resulting image per format, comma divided. Example: `jpeg=70,avif=40,webp=60`. When value for the resulting format is not set, `IMGPROXY_QUALITY` value is used. Default: `avif=50`. * `IMGPROXY_FORMAT_QUALITY`: default quality of the resulting image per format, separated by commas. Example: `jpeg=70,avif=40,webp=60`. When a value for the resulting format is not set, the `IMGPROXY_QUALITY` value is used. Default: `avif=50`
### Advanced JPEG compression ### Advanced JPEG compression
* `IMGPROXY_JPEG_PROGRESSIVE`: when true, enables progressive JPEG compression. Default: false; * `IMGPROXY_JPEG_PROGRESSIVE`: when true, enables progressive JPEG compression. Default: `false`
* `IMGPROXY_JPEG_NO_SUBSAMPLE`: <i class='badge badge-pro'></i> when true, chrominance subsampling is disabled. This will improve quality at the cost of larger file size. Default: false; * `IMGPROXY_JPEG_NO_SUBSAMPLE`: <i class='badge badge-pro'></i> when true, chrominance subsampling is disabled. This will improve quality at the cost of larger file size. Default: `false`
* `IMGPROXY_JPEG_TRELLIS_QUANT`: <i class='badge badge-pro'></i> when true, enables trellis quantisation for each 8x8 block. Reduces file size but increases compression time. Default: false; * `IMGPROXY_JPEG_TRELLIS_QUANT`: <i class='badge badge-pro'></i> when true, enables trellis quantisation for each 8x8 block. Reduces file size but increases compression time. Default: `false`
* `IMGPROXY_JPEG_OVERSHOOT_DERINGING`: <i class='badge badge-pro'></i> when true, enables overshooting of samples with extreme values. Overshooting may reduce ringing artifacts from compression, in particular in areas where black text appears on a white background. Default: false; * `IMGPROXY_JPEG_OVERSHOOT_DERINGING`: <i class='badge badge-pro'></i> when true, enables overshooting of samples with extreme values. Overshooting may reduce ringing artifacts from compression, in particular in areas where black text appears on a white background. Default: `false`
* `IMGPROXY_JPEG_OPTIMIZE_SCANS`: <i class='badge badge-pro'></i> when true, split the spectrum of DCT coefficients into separate scans. Reduces file size but increases compression time. Requires `IMGPROXY_JPEG_PROGRESSIVE` to be true. Default: false; * `IMGPROXY_JPEG_OPTIMIZE_SCANS`: <i class='badge badge-pro'></i> when true, splits the spectrum of DCT coefficients into separate scans. Reduces file size but increases compression time. Requires `IMGPROXY_JPEG_PROGRESSIVE` to be true. Default: `false`
* `IMGPROXY_JPEG_QUANT_TABLE`: <i class='badge badge-pro'></i> quantization table to use. Supported values are: * `IMGPROXY_JPEG_QUANT_TABLE`: <i class='badge badge-pro'></i> quantization table to use. Supported values are:
* `0`: Table from JPEG Annex K (default); * `0`: Table from JPEG Annex K (default)
* `1`: Flat table; * `1`: Flat table
* `2`: Table tuned for MSSIM on Kodak image set; * `2`: Table tuned for MSSIM on Kodak image set
* `3`: Table from ImageMagick by N. Robidoux; * `3`: Table from ImageMagick by N. Robidoux
* `4`: Table tuned for PSNR-HVS-M on Kodak image set; * `4`: Table tuned for PSNR-HVS-M on Kodak image set
* `5`: Table from Relevance of Human Vision to JPEG-DCT Compression (1992); * `5`: Table from Relevance of Human Vision to JPEG-DCT Compression (1992)
* `6`: Table from DCTune Perceptual Optimization of Compressed Dental X-Rays (1997); * `6`: Table from DCTune Perceptual Optimization of Compressed Dental X-Rays (1997)
* `7`: Table from A Visual Detection Model for DCT Coefficient Quantization (1993); * `7`: Table from A Visual Detection Model for DCT Coefficient Quantization (1993)
* `8`: Table from An Improved Detection Model for DCT Coefficient Quantization (1993). * `8`: Table from An Improved Detection Model for DCT Coefficient Quantization (1993)
**📝Note:** `IMGPROXY_JPEG_TRELLIS_QUANT`, `IMGPROXY_JPEG_OVERSHOOT_DERINGING`, `IMGPROXY_JPEG_OPTIMIZE_SCANS`, and `IMGPROXY_JPEG_QUANT_TABLE` require libvips to be built with [MozJPEG](https://github.com/mozilla/mozjpeg) since standard libjpeg doesn't support those optimizations. **📝Note:** `IMGPROXY_JPEG_TRELLIS_QUANT`, `IMGPROXY_JPEG_OVERSHOOT_DERINGING`, `IMGPROXY_JPEG_OPTIMIZE_SCANS`, and `IMGPROXY_JPEG_QUANT_TABLE` require libvips to be built with [MozJPEG](https://github.com/mozilla/mozjpeg) since standard libjpeg doesn't support those optimizations.
### Advanced PNG compression ### Advanced PNG compression
* `IMGPROXY_PNG_INTERLACED`: when true, enables interlaced PNG compression. Default: false; * `IMGPROXY_PNG_INTERLACED`: when true, enables interlaced PNG compression. Default: `false`
* `IMGPROXY_PNG_QUANTIZE`: when true, enables PNG quantization. libvips should be built with [Quantizr](https://github.com/DarthSim/quantizr) or libimagequant support. Default: false; * `IMGPROXY_PNG_QUANTIZE`: when true, enables PNG quantization. libvips should be built with [Quantizr](https://github.com/DarthSim/quantizr) or libimagequant support. Default: `false`
* `IMGPROXY_PNG_QUANTIZATION_COLORS`: maximum number of quantization palette entries. Should be between 2 and 256. Default: 256; * `IMGPROXY_PNG_QUANTIZATION_COLORS`: maximum number of quantization palette entries. Should be between 2 and 256. Default: 256
### Advanced GIF compression ### Advanced GIF compression
* `IMGPROXY_GIF_OPTIMIZE_FRAMES`: <i class='badge badge-pro'></i> when true, enables GIF frames optimization. This may produce a smaller result, but may increase compression time. * `IMGPROXY_GIF_OPTIMIZE_FRAMES`: <i class='badge badge-pro'></i> when true, enables GIF frame optimization. This may produce a smaller result, but may increase compression time.
* `IMGPROXY_GIF_OPTIMIZE_TRANSPARENCY`: <i class='badge badge-pro'></i> when true, enables GIF transparency optimization. This may produce a smaller result, but may increase compression time. * `IMGPROXY_GIF_OPTIMIZE_TRANSPARENCY`: <i class='badge badge-pro'></i> when true, enables GIF transparency optimization. This may produce a smaller result, but may also increase compression time.
### Advanced AVIF compression ### Advanced AVIF compression
* `IMGPROXY_AVIF_SPEED`: controls the CPU effort spent improving compression. 0 slowest - 8 fastest. Default: `5`; * `IMGPROXY_AVIF_SPEED`: controls the CPU effort spent improving compression. The lowest speed is at 0 and the fastest is at 8. Default: `5`
### Autoquality ### Autoquality
@ -146,25 +149,25 @@ imgproxy can calculate the quality of the resulting image based on selected metr
**⚠️Warning:** Autoquality requires the image to be saved several times. Use it only when you prefer the resulting size and quality over the speed. **⚠️Warning:** Autoquality requires the image to be saved several times. Use it only when you prefer the resulting size and quality over the speed.
* `IMGPROXY_AUTOQUALITY_METHOD`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the method of quality calculation. Default: `none`. * `IMGPROXY_AUTOQUALITY_METHOD`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the method of quality calculation. Default: `none`
* `IMGPROXY_AUTOQUALITY_TARGET`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> desired value of the autoquality method metric. Default: 0.02. * `IMGPROXY_AUTOQUALITY_TARGET`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> desired value of the autoquality method metric. Default: 0.02
* `IMGPROXY_AUTOQUALITY_MIN`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> minimal quality imgproxy can use. Default: 70. * `IMGPROXY_AUTOQUALITY_MIN`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> minimal quality imgproxy can use. Default: 70
* `IMGPROXY_AUTOQUALITY_FORMAT_MIN`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> minimal quality imgproxy can use per format, comma divided. Example: `jpeg=70,avif=40,webp=60`. When value for the resulting format is not set, `IMGPROXY_AUTOQUALITY_MIN` value is used. Default: `avif=40`. * `IMGPROXY_AUTOQUALITY_FORMAT_MIN`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the minimal quality imgproxy can use per format, comma divided. Example: `jpeg=70,avif=40,webp=60`. When value for the resulting format is not set, `IMGPROXY_AUTOQUALITY_MIN` value is used. Default: `avif=40`
* `IMGPROXY_AUTOQUALITY_MAX`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> maximal quality imgproxy can use. Default: 80. * `IMGPROXY_AUTOQUALITY_MAX`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the maximum quality imgproxy can use. Default: 80
* `IMGPROXY_AUTOQUALITY_FORMAT_MAX`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> maximal quality imgproxy can use per format, comma divided. Example: `jpeg=70,avif=40,webp=60`. When value for the resulting format is not set, `IMGPROXY_AUTOQUALITY_MAX` value is used. Default: `avif=50`. * `IMGPROXY_AUTOQUALITY_FORMAT_MAX`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the maximum quality imgproxy can use per format, comma divided. Example: `jpeg=70,avif=40,webp=60`. When a value for the resulting format is not set, the `IMGPROXY_AUTOQUALITY_MAX` value is used. Default: `avif=50`
* `IMGPROXY_AUTOQUALITY_ALLOWED_ERROR`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> allowed `IMGPROXY_AUTOQUALITY_TARGET` error. Applicable only to `dssim` and `ml` methods. Default: 0.001. * `IMGPROXY_AUTOQUALITY_ALLOWED_ERROR`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the allowed `IMGPROXY_AUTOQUALITY_TARGET` error. Applicable only to `dssim` and `ml` methods. Default: 0.001
* `IMGPROXY_AUTOQUALITY_MAX_RESOLUTION`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> when value is greater then zero and the result resolution exceeds the value, autoquality won't be used. Default: 0. * `IMGPROXY_AUTOQUALITY_MAX_RESOLUTION`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> when this value is greater then zero and the resultant resolution exceeds the value, autoquality won't be used. Default: 0
* `IMGPROXY_AUTOQUALITY_JPEG_NET`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> path to the neural network for JPEG. * `IMGPROXY_AUTOQUALITY_JPEG_NET`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the path to the neural network for JPEG.
* `IMGPROXY_AUTOQUALITY_WEBP_NET`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> path to the neural network for WebP. * `IMGPROXY_AUTOQUALITY_WEBP_NET`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the path to the neural network for WebP.
* `IMGPROXY_AUTOQUALITY_AVIF_NET`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> path to the neural network for AVIF. * `IMGPROXY_AUTOQUALITY_AVIF_NET`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the path to the neural network for AVIF.
## AVIF/WebP support detection ## AVIF/WebP support detection
imgproxy can use the `Accept` HTTP header to detect if the browser supports AVIF or WebP and use it as the default format. This feature is disabled by default and can be enabled by the following options: imgproxy can use the `Accept` HTTP header to detect if the browser supports AVIF or WebP and use it as the default format. This feature is disabled by default and can be enabled by the following options:
* `IMGPROXY_ENABLE_WEBP_DETECTION`: enables WebP support detection. When the file extension is omitted in the imgproxy URL and browser supports WebP, imgproxy will use it as the resulting format; * `IMGPROXY_ENABLE_WEBP_DETECTION`: enables WebP support detection. When the file extension is omitted in the imgproxy URL and browser supports WebP, imgproxy will use it as the resulting format.
* `IMGPROXY_ENFORCE_WEBP`: enables WebP support detection and enforces WebP usage. If the browser supports WebP, it will be used as resulting format even if another extension is specified in the imgproxy URL. * `IMGPROXY_ENFORCE_WEBP`: enables WebP support detection and enforces WebP usage. If the browser supports WebP, it will be used as resulting format even if another extension is specified in the imgproxy URL.
* `IMGPROXY_ENABLE_AVIF_DETECTION`: enables AVIF support detection. When the file extension is omitted in the imgproxy URL and browser supports AVIF, imgproxy will use it as the resulting format; * `IMGPROXY_ENABLE_AVIF_DETECTION`: enables AVIF support detection. When the file extension is omitted in the imgproxy URL and browser supports AVIF, imgproxy will use it as the resulting format.
* `IMGPROXY_ENFORCE_AVIF`: enables AVIF support detection and enforces AVIF usage. If the browser supports AVIF, it will be used as resulting format even if another extension is specified in the imgproxy URL. * `IMGPROXY_ENFORCE_AVIF`: enables AVIF support detection and enforces AVIF usage. If the browser supports AVIF, it will be used as resulting format even if another extension is specified in the imgproxy URL.
**📝Note:** imgproxy prefers AVIF over WebP. This means that if both AVIF and WebP detection/enforcement are enabled and the browser supports both of them, AVIF will be used. **📝Note:** imgproxy prefers AVIF over WebP. This means that if both AVIF and WebP detection/enforcement are enabled and the browser supports both of them, AVIF will be used.
@ -173,88 +176,88 @@ imgproxy can use the `Accept` HTTP header to detect if the browser supports AVIF
**📝Note:** When AVIF/WebP support detection is enabled, please take care to configure your CDN or caching proxy to take the `Accept` HTTP header into account while caching. **📝Note:** When AVIF/WebP support detection is enabled, please take care to configure your CDN or caching proxy to take the `Accept` HTTP header into account while caching.
**⚠️Warning:** Headers cannot be signed. This means that an attacker can bypass your CDN cache by changing the `Accept` HTTP headers. Have this in mind when configuring your production caching setup. **⚠️Warning:** Headers cannot be signed. This means that an attacker can bypass your CDN cache by changing the `Accept` HTTP headers. Keep this in mind when configuring your production caching setup.
## Client Hints support ## Client Hints support
imgproxy can use the `Width`, `Viewport-Width` or `DPR` HTTP headers to determine default width and DPR options using Client Hints. This feature is disabled by default and can be enabled by the following option: imgproxy can use the `Width`, `Viewport-Width` or `DPR` HTTP headers to determine default width and DPR options using Client Hints. This feature is disabled by default and can be enabled by the following option:
* `IMGPROXY_ENABLE_CLIENT_HINTS`: enables Client Hints support to determine default width and DPR options. Read [here](https://developers.google.com/web/updates/2015/09/automating-resource-selection-with-client-hints) details about Client Hints. * `IMGPROXY_ENABLE_CLIENT_HINTS`: enables Client Hints support to determine default width and DPR options. Read more details [here](https://developers.google.com/web/updates/2015/09/automating-resource-selection-with-client-hints) about Client Hints.
**⚠️Warning:** Headers cannot be signed. This means that an attacker can bypass your CDN cache by changing the `Width`, `Viewport-Width` or `DPR` HTTP headers. Have this in mind when configuring your production caching setup. **⚠️Warning:** Headers cannot be signed. This means that an attacker can bypass your CDN cache by changing the `Width`, `Viewport-Width` or `DPR` HTTP headers. Keep this in mind when configuring your production caching setup.
## Video thumbnails ## Video thumbnails
imgproxy Pro can extract specific frames of videos to create thumbnails. The feature is disabled by default, but can be enabled with `IMGPROXY_ENABLE_VIDEO_THUMBNAILS`. imgproxy Pro can extract specific video frames to create thumbnails. This feature is disabled by default, but can be enabled with `IMGPROXY_ENABLE_VIDEO_THUMBNAILS`.
* `IMGPROXY_ENABLE_VIDEO_THUMBNAILS`: <i class='badge badge-pro'></i> then true, enables video thumbnails generation. Default: false; * `IMGPROXY_ENABLE_VIDEO_THUMBNAILS`: <i class='badge badge-pro'></i> when true, enables video thumbnail generation. Default: `false`
* `IMGPROXY_VIDEO_THUMBNAIL_SECOND`: <i class='badge badge-pro'></i> the timestamp of the frame in seconds that will be used for a thumbnail. Default: 1. * `IMGPROXY_VIDEO_THUMBNAIL_SECOND`: <i class='badge badge-pro'></i> the timestamp of the frame (in seconds) that will be used for a thumbnail. Default: 1
* `IMGPROXY_VIDEO_THUMBNAIL_PROBE_SIZE`: <i class='badge badge-pro'></i> the maximum amount of bytes used to determine the format. Lower values can decrease memory usage but can produce inaccurate data or even lead to errors. Default: 5000000. * `IMGPROXY_VIDEO_THUMBNAIL_PROBE_SIZE`: <i class='badge badge-pro'></i> the maximum amount of bytes used to determine the format. Lower values can decrease memory usage but can produce inaccurate data, or even lead to errors. Default: 5000000
* `IMGPROXY_VIDEO_THUMBNAIL_MAX_ANALYZE_DURATION`: <i class='badge badge-pro'></i> the maximum of milliseconds used to get the stream info. Low values can decrease memory usage but can produce inaccurate data or even lead to errors. When set to 0, the heuristic is used. Default: 0. * `IMGPROXY_VIDEO_THUMBNAIL_MAX_ANALYZE_DURATION`: <i class='badge badge-pro'></i> the maximum number of milliseconds used to get the stream info. Lower values can decrease memory usage but can produce inaccurate data, or even lead to errors. When set to 0, the heuristic is used. Default: 0
**⚠️Warning:** Though using `IMGPROXY_VIDEO_THUMBNAIL_PROBE_SIZE` and `IMGPROXY_VIDEO_THUMBNAIL_MAX_ANALYZE_DURATION` can lower the memory footprint of video thumbnails generation, you should use them in production only when you know what are you doing. **⚠️Warning:** Though using `IMGPROXY_VIDEO_THUMBNAIL_PROBE_SIZE` and `IMGPROXY_VIDEO_THUMBNAIL_MAX_ANALYZE_DURATION` can lower the memory footprint of video thumbnail generation, they should be used in production only when you know what you're doing.
## Watermark ## Watermark
* `IMGPROXY_WATERMARK_DATA`: Base64-encoded image data. You can easily calculate it with `base64 tmp/watermark.png | tr -d '\n'`; * `IMGPROXY_WATERMARK_DATA`: Base64-encoded image data. You can easily calculate it with `base64 tmp/watermark.png | tr -d '\n'`.
* `IMGPROXY_WATERMARK_PATH`: path to the locally stored image; * `IMGPROXY_WATERMARK_PATH`: the path to the locally stored image
* `IMGPROXY_WATERMARK_URL`: watermark image URL; * `IMGPROXY_WATERMARK_URL`: the watermark image URL
* `IMGPROXY_WATERMARK_OPACITY`: watermark base opacity; * `IMGPROXY_WATERMARK_OPACITY`: the watermark's base opacity
* `IMGPROXY_WATERMARKS_CACHE_SIZE`: <i class='badge badge-pro'></i> size of custom watermarks cache. When set to `0`, watermarks cache is disabled. By default 256 watermarks are cached. * `IMGPROXY_WATERMARKS_CACHE_SIZE`: <i class='badge badge-pro'></i> custom watermarks cache size. When set to `0`, the watermark cache is disabled. 256 watermarks are cached by default.
Read more about watermarks in the [Watermark](watermark.md) guide. Read more about watermarks in the [Watermark](watermark.md) guide.
## Unsharpening ## Unsharpening
imgproxy Pro can apply unsharpening mask to your images. imgproxy Pro can apply an unsharpening mask to your images.
* `IMGPROXY_UNSHARPENING_MODE`: <i class='badge badge-pro'></i> controls when unsharpenning mask should be applied. The following modes are supported: * `IMGPROXY_UNSHARPENING_MODE`: <i class='badge badge-pro'></i> controls when an unsharpenning mask should be applied. The following modes are supported:
* `auto`: _(default)_ apply unsharpening mask only when image is downscaled and `sharpen` option is not set. * `auto`: _(default)_ apply an unsharpening mask only when an image is downscaled and the `sharpen` option has not been set.
* `none`: don't apply the unsharpening mask. * `none`: the unsharpening mask is not applied.
* `always`: always apply the unsharpening mask. * `always`: always applies the unsharpening mask.
* `IMGPROXY_UNSHARPENING_WEIGHT`: <i class='badge badge-pro'></i> a floating-point number that defines how neighbor pixels will affect the current pixel. Greater the value - sharper the image. Should be greater than zero. Default: `1`. * `IMGPROXY_UNSHARPENING_WEIGHT`: <i class='badge badge-pro'></i> a floating-point number that defines how neighboring pixels will affect the current pixel. The greater the value, the sharper the image. This value should be greater than zero. Default: `1`
* `IMGPROXY_UNSHARPENING_DIVIDOR`: <i class='badge badge-pro'></i> a floating-point number that defines the unsharpening strength. Lesser the value - sharper the image. Should be greater than zero. Default: `24`. * `IMGPROXY_UNSHARPENING_DIVIDOR`: <i class='badge badge-pro'></i> a floating-point number that defines the unsharpening strength. The lesser the value, the sharper the image. This value be greater than zero. Default: `24`
## Object detection ## Object detection
imgproxy can detect objects on the image and use them for smart crop, bluring the detections, or drawing the detections. imgproxy can detect objects on the image and use them to perform smart cropping, to blur the detections, or to draw the detections.
* `IMGPROXY_OBJECT_DETECTION_CONFIG`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> path to the neural network config. Default: blank. * `IMGPROXY_OBJECT_DETECTION_CONFIG`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the path to the neural network config. Default: blank
* `IMGPROXY_OBJECT_DETECTION_WEIGHTS`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> path to the neural network weights. Default: blank. * `IMGPROXY_OBJECT_DETECTION_WEIGHTS`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the path to the neural network weights. Default: blank
* `IMGPROXY_OBJECT_DETECTION_CLASSES`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> path to the text file with the classes names, one by line. Default: blank. * `IMGPROXY_OBJECT_DETECTION_CLASSES`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the path to the text file with the classes names, one per line. Default: blank
* `IMGPROXY_OBJECT_DETECTION_NET_SIZE`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> 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: 416. * `IMGPROXY_OBJECT_DETECTION_NET_SIZE`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> 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: 416
* `IMGPROXY_OBJECT_DETECTION_CONFIDENCE_THRESHOLD`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the detections with confidences below this value will be discarded. Default: 0.2. * `IMGPROXY_OBJECT_DETECTION_CONFIDENCE_THRESHOLD`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> detections with confidences below this value will be discarded. Default: 0.2
* `IMGPROXY_OBJECT_DETECTION_NMS_THRESHOLD`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> non max supression threshold. Don't change this if you don't know what you're doing. Default: 0.4. * `IMGPROXY_OBJECT_DETECTION_NMS_THRESHOLD`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> non-max supression threshold. Don't change this if you don't know what you're doing. Default: 0.4
## Fallback image ## Fallback image
You can set up a fallback image that will be used in case imgproxy can't fetch the requested one. Use one of the following variables: You can set up a fallback image that will be used in case imgproxy is unable to fetch the requested one. Use one of the following variables:
* `IMGPROXY_FALLBACK_IMAGE_DATA`: Base64-encoded image data. You can easily calculate it with `base64 tmp/fallback.png | tr -d '\n'`; * `IMGPROXY_FALLBACK_IMAGE_DATA`: Base64-encoded image data. You can easily calculate it with `base64 tmp/fallback.png | tr -d '\n'`.
* `IMGPROXY_FALLBACK_IMAGE_PATH`: path to the locally stored image; * `IMGPROXY_FALLBACK_IMAGE_PATH`: the path to the locally stored image
* `IMGPROXY_FALLBACK_IMAGE_URL`: fallback image URL. * `IMGPROXY_FALLBACK_IMAGE_URL`: the fallback image URL
* `IMGPROXY_FALLBACK_IMAGE_HTTP_CODE`: <i class='badge badge-v3'></i> HTTP code for the fallback image response. When set to zero, imgproxy will respond with the usual HTTP code. Default: `200`. * `IMGPROXY_FALLBACK_IMAGE_HTTP_CODE`: the <i class='badge badge-v3'></i> HTTP code for the fallback image response. When set to zero, imgproxy will respond with the usual HTTP code. Default: `200`
* `IMGPROXY_FALLBACK_IMAGES_CACHE_SIZE`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> size of custom fallback images cache. When set to `0`, fallback images cache is disabled. By default 256 fallback images are cached. * `IMGPROXY_FALLBACK_IMAGES_CACHE_SIZE`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> the size of custom fallback images cache. When set to `0`, the fallback image cache is disabled. 256 fallback images are cached by default.
## Skip processing ## Skip processing
You can configure imgproxy to skip processing of some formats: You can configure imgproxy to skip processing of some formats:
* `IMGPROXY_SKIP_PROCESSING_FORMATS`: list of formats that imgproxy shouldn't process, comma-divided. * `IMGPROXY_SKIP_PROCESSING_FORMATS`: a list of formats that imgproxy shouldn't process, comma divided.
**📝Note:** Processing can be skipped only when the requested format is the same as the source format. **📝Note:** Processing can only be skipped when the requested format is the same as the source format.
**📝Note:** Video thumbnail processing can't be skipped. **📝Note:** Video thumbnail processing can't be skipped.
## Presets ## Presets
Read about imgproxy presets in the [Presets](presets.md) guide. Read more about imgproxy presets in the [Presets](presets.md) guide.
There are two ways to define presets: There are two ways to define presets:
#### Using an environment variable #### Using an environment variable
* `IMGPROXY_PRESETS`: set of preset definitions, comma-divided. Example: `default=resizing_type:fill/enlarge:1,sharp=sharpen:0.7,blurry=blur:2`. Default: blank. * `IMGPROXY_PRESETS`: a set of preset definitions, comma divided. Example: `default=resizing_type:fill/enlarge:1,sharp=sharpen:0.7,blurry=blur:2`. Default: blank
#### Using a command line argument #### Using a command line argument
@ -262,7 +265,7 @@ There are two ways to define presets:
imgproxy -presets /path/to/file/with/presets imgproxy -presets /path/to/file/with/presets
``` ```
The file should contain preset definitions, one per line. Lines starting with `#` are treated as comments. Example: This file should contain preset definitions, one per line. Lines starting with `#` are treated as comments. Example:
``` ```
default=resizing_type:fill/enlarge:1 default=resizing_type:fill/enlarge:1
@ -278,13 +281,13 @@ blurry=blur:2
imgproxy can be switched into "presets-only mode". In this mode, imgproxy accepts only `preset` option arguments as processing options. Example: `http://imgproxy.example.com/unsafe/thumbnail:blurry:watermarked/plain/http://example.com/images/curiosity.jpg@png` imgproxy can be switched into "presets-only mode". In this mode, imgproxy accepts only `preset` option arguments as processing options. Example: `http://imgproxy.example.com/unsafe/thumbnail:blurry:watermarked/plain/http://example.com/images/curiosity.jpg@png`
* `IMGPROXY_ONLY_PRESETS`: disable all URL formats and enable presets-only mode. * `IMGPROXY_ONLY_PRESETS`: disables all URL formats and enables presets-only mode.
## Serving local files ## Serving local files
imgproxy can serve your local images, but this feature is disabled by default. To enable it, specify your local filesystem root: imgproxy can serve your local images, but this feature is disabled by default. To enable it, specify your local filesystem root:
* `IMGPROXY_LOCAL_FILESYSTEM_ROOT`: the root of the local filesystem. Keep empty to disable serving of local files. * `IMGPROXY_LOCAL_FILESYSTEM_ROOT`: the root of the local filesystem. Keep this empty to disable local file serving.
Check out the [Serving local files](serving_local_files.md) guide to learn more. Check out the [Serving local files](serving_local_files.md) guide to learn more.
@ -292,16 +295,16 @@ Check out the [Serving local files](serving_local_files.md) guide to learn more.
imgproxy can process files from Amazon S3 buckets, but this feature is disabled by default. To enable it, set `IMGPROXY_USE_S3` to `true`: imgproxy can process files from Amazon S3 buckets, but this feature is disabled by default. To enable it, set `IMGPROXY_USE_S3` to `true`:
* `IMGPROXY_USE_S3`: when `true`, enables image fetching from Amazon S3 buckets. Default: false; * `IMGPROXY_USE_S3`: when `true`, enables image fetching from Amazon S3 buckets. Default: `false`
* `IMGPROXY_S3_ENDPOINT`: custom S3 endpoint to being used by imgproxy. * `IMGPROXY_S3_ENDPOINT`: a custom S3 endpoint to being used by imgproxy
Check out the [Serving files from S3](serving_files_from_s3.md) guide to learn more. Check out the [Serving files from S3](serving_files_from_s3.md) guide to learn more.
## Serving files from Google Cloud Storage ## Serving files from Google Cloud Storage
imgproxy can process files from Google Cloud Storage buckets, but this feature is disabled by default. To enable it, set `IMGPROXY_GCS_KEY` to the content of Google Cloud JSON key: imgproxy can process files from Google Cloud Storage buckets, but this feature is disabled by default. To enable it, set the value of `IMGPROXY_GCS_KEY` to the content of the Google Cloud JSON key:
* `IMGPROXY_GCS_KEY`: Google Cloud JSON key. When set, enables image fetching from Google Cloud Storage buckets. Default: blank. * `IMGPROXY_GCS_KEY`: the Google Cloud JSON key. When set, enables image fetching from Google Cloud Storage buckets. Default: blank
Check out the [Serving files from Google Cloud Storage](serving_files_from_google_cloud_storage.md) guide to learn more. Check out the [Serving files from Google Cloud Storage](serving_files_from_google_cloud_storage.md) guide to learn more.
@ -309,10 +312,10 @@ Check out the [Serving files from Google Cloud Storage](serving_files_from_googl
imgproxy can process files from Azure Blob Storage containers, but this feature is disabled by default. To enable it, set `IMGPROXY_USE_ABS` to `true`: imgproxy can process files from Azure Blob Storage containers, but this feature is disabled by default. To enable it, set `IMGPROXY_USE_ABS` to `true`:
* `IMGPROXY_USE_ABS`: when `true`, enables image fetching from Azure Blob Storage containers. Default: false; * `IMGPROXY_USE_ABS`: when `true`, enables image fetching from Azure Blob Storage containers. Default: `false`
* `IMGPROXY_ABS_NAME`: Azure account name. Default: blank; * `IMGPROXY_ABS_NAME`: the Azure account name. Default: blank
* `IMGPROXY_ABS_KEY`: Azure account key. Default: blank; * `IMGPROXY_ABS_KEY`: the Azure account key. Default: blank
* `IMGPROXY_ABS_ENDPOINT`: custom Azure Blob Storage endpoint to being used by imgproxy. Default: blank. * `IMGPROXY_ABS_ENDPOINT`: the custom Azure Blob Storage endpoint to be used by imgproxy. Default: blank
Check out the [Serving files from Azure Blob Storage](serving_files_from_azure_blob_storage.md) guide to learn more. Check out the [Serving files from Azure Blob Storage](serving_files_from_azure_blob_storage.md) guide to learn more.
@ -320,17 +323,17 @@ Check out the [Serving files from Azure Blob Storage](serving_files_from_azure_b
imgproxy can send its metrics to New Relic. Specify your New Relic license key to activate this feature: imgproxy can send its metrics to New Relic. Specify your New Relic license key to activate this feature:
* `IMGPROXY_NEW_RELIC_KEY`: New Relic license key; * `IMGPROXY_NEW_RELIC_KEY`: the New Relic license key
* `IMGPROXY_NEW_RELIC_APP_NAME`: New Relic application name. Default: `imgproxy`. * `IMGPROXY_NEW_RELIC_APP_NAME`: a New Relic application name. Default: `imgproxy`
Check out the [New Relic](new_relic.md) guide to learn more. Check out the [New Relic](new_relic.md) guide to learn more.
## Prometheus metrics ## Prometheus metrics
imgproxy can collect its metrics for Prometheus. Specify binding for Prometheus metrics server to activate this feature: imgproxy can collect its metrics for Prometheus. Specify a binding for Prometheus metrics server to activate this feature:
* `IMGPROXY_PROMETHEUS_BIND`: Prometheus metrics server binding. Can't be the same as `IMGPROXY_BIND`. Default: blank. * `IMGPROXY_PROMETHEUS_BIND`: Prometheus metrics server binding. Can't be the same as `IMGPROXY_BIND`. Default: blank
* `IMGPROXY_PROMETHEUS_NAMESPACE`: Namespace (prefix) for imgproxy metrics. Default: blank. * `IMGPROXY_PROMETHEUS_NAMESPACE`: Namespace (prefix) for imgproxy metrics. Default: blank
Check out the [Prometheus](prometheus.md) guide to learn more. Check out the [Prometheus](prometheus.md) guide to learn more.
@ -338,7 +341,7 @@ Check out the [Prometheus](prometheus.md) guide to learn more.
imgproxy can send its metrics to Datadog: imgproxy can send its metrics to Datadog:
* `IMGPROXY_DATADOG_ENABLE`: <i class='badge badge-v3'></i> when `true`, enables sending metrics to Datadog. Default: false; * `IMGPROXY_DATADOG_ENABLE`: <i class='badge badge-v3'></i> when `true`, enables sending metrics to Datadog. Default: false
Check out the [Datadog](datadog.md) guide to learn more. Check out the [Datadog](datadog.md) guide to learn more.
@ -346,50 +349,50 @@ Check out the [Datadog](datadog.md) guide to learn more.
imgproxy can report occurred errors to Bugsnag, Honeybadger and Sentry: imgproxy can report occurred errors to Bugsnag, Honeybadger and Sentry:
* `IMGPROXY_BUGSNAG_KEY`: Bugsnag API key. When provided, enables error reporting to Bugsnag; * `IMGPROXY_BUGSNAG_KEY`: Bugsnag API key. When provided, enables error reporting to Bugsnag.
* `IMGPROXY_BUGSNAG_STAGE`: Bugsnag stage to report to. Default: `production`; * `IMGPROXY_BUGSNAG_STAGE`: the Bugsnag stage to report to. Default: `production`
* `IMGPROXY_HONEYBADGER_KEY`: Honeybadger API key. When provided, enables error reporting to Honeybadger; * `IMGPROXY_HONEYBADGER_KEY`: the Honeybadger API key. When provided, enables error reporting to Honeybadger.
* `IMGPROXY_HONEYBADGER_ENV`: Honeybadger env to report to. Default: `production`; * `IMGPROXY_HONEYBADGER_ENV`: the Honeybadger env to report to. Default: `production`
* `IMGPROXY_SENTRY_DSN`: Sentry project DSN. When provided, enables error reporting to Sentry; * `IMGPROXY_SENTRY_DSN`: Sentry project DSN. When provided, enables error reporting to Sentry.
* `IMGPROXY_SENTRY_ENVIRONMENT`: Sentry environment to report to. Default: `production`; * `IMGPROXY_SENTRY_ENVIRONMENT`: the Sentry environment to report to. Default: `production`
* `IMGPROXY_SENTRY_RELEASE`: Sentry release to report to. Default: `imgproxy@{imgproxy version}`; * `IMGPROXY_SENTRY_RELEASE`: the Sentry release to report to. Default: `imgproxy@{imgproxy version}`
* `IMGPROXY_AIRBRAKE_PROJECT_ID`: Airbrake project id; * `IMGPROXY_AIRBRAKE_PROJECT_ID`: an Airbrake project id
* `IMGPROXY_AIRBRAKE_PROJECT_KEY`: Airbrake project key; * `IMGPROXY_AIRBRAKE_PROJECT_KEY`: an Airbrake project key
* `IMGPROXY_AIRBRAKE_ENVIRONMENT`: Airbrake environment to report to. Default: `production`; * `IMGPROXY_AIRBRAKE_ENVIRONMENT`: the Airbrake environment to report to. Default: `production`
* `IMGPROXY_REPORT_DOWNLOADING_ERRORS`: when `true`, imgproxy will report downloading errors. Default: `true`. * `IMGPROXY_REPORT_DOWNLOADING_ERRORS`: when `true`, imgproxy will report downloading errors. Default: `true`
## Log ## Log
* `IMGPROXY_LOG_FORMAT`: the log format. The following formats are supported: * `IMGPROXY_LOG_FORMAT`: the log format. The following formats are supported:
* `pretty`: _(default)_ colored human-readable format; * `pretty`: _(default)_ colored human-readable format
* `structured`: machine-readable format; * `structured`: machine-readable format
* `json`: JSON format; * `json`: JSON format
* `IMGPROXY_LOG_LEVEL`: the log level. The following levels are supported `error`, `warn`, `info` and `debug`. Default: `info`; * `IMGPROXY_LOG_LEVEL`: the log level. The following levels are supported `error`, `warn`, `info` and `debug`. Default: `info`
imgproxy can send logs to syslog, but this feature is disabled by default. To enable it, set `IMGPROXY_SYSLOG_ENABLE` to `true`: imgproxy can send logs to syslog, but this feature is disabled by default. To enable it, set `IMGPROXY_SYSLOG_ENABLE` to `true`:
* `IMGPROXY_SYSLOG_ENABLE`: when `true`, enables sending logs to syslog; * `IMGPROXY_SYSLOG_ENABLE`: when `true`, enables sending logs to syslog.
* `IMGPROXY_SYSLOG_LEVEL`: maximum log level to send to syslog. Known levels are: `crit`, `error`, `warning` and `info`. Default: `info`; * `IMGPROXY_SYSLOG_LEVEL`: the maximum log level to send to syslog. Known levels are: `crit`, `error`, `warning` and `info`. Default: `info`
* `IMGPROXY_SYSLOG_NETWORK`: network that will be used to connect to syslog. When blank, the local syslog server will be used. Known networks are `tcp`, `tcp4`, `tcp6`, `udp`, `udp4`, `udp6`, `ip`, `ip4`, `ip6`, `unix`, `unixgram` and `unixpacket`. Default: blank; * `IMGPROXY_SYSLOG_NETWORK`: the network that will be used to connect to syslog. When blank, the local syslog server will be used. Known networks are `tcp`, `tcp4`, `tcp6`, `udp`, `udp4`, `udp6`, `ip`, `ip4`, `ip6`, `unix`, `unixgram` and `unixpacket`. Default: blank
* `IMGPROXY_SYSLOG_ADDRESS`: address of the syslog service. Not used if `IMGPROXY_SYSLOG_NETWORK` is blank. Default: blank; * `IMGPROXY_SYSLOG_ADDRESS`: the address of the syslog service. Not used if `IMGPROXY_SYSLOG_NETWORK` is blank. Default: blank
* `IMGPROXY_SYSLOG_TAG`: specific syslog tag. Default: `imgproxy`; * `IMGPROXY_SYSLOG_TAG`: the specific syslog tag. Default: `imgproxy`
**📝Note:** imgproxy always uses structured log format for syslog. **📝Note:** imgproxy always uses structured log format for syslog.
## Memory usage tweaks ## Memory usage tweaks
**⚠️Warning:** It's highly recommended to read [Memory usage tweaks](memory_usage_tweaks.md) guide before changing this settings. **⚠️Warning:** We highly recommended reading the [Memory usage tweaks](memory_usage_tweaks.md) guide before changing these settings.
* `IMGPROXY_DOWNLOAD_BUFFER_SIZE`: the initial size (in bytes) of a single download buffer. When zero, initializes empty download buffers. Default: `0`; * `IMGPROXY_DOWNLOAD_BUFFER_SIZE`: the initial size (in bytes) of a single download buffer. When set to zero, initializes empty download buffers. Default: `0`
* `IMGPROXY_GZIP_BUFFER_SIZE`: the initial size (in bytes) of a single GZip buffer. When zero, initializes empty GZip buffers. Makes sense only when GZip compression is enabled. Default: `0`; * `IMGPROXY_GZIP_BUFFER_SIZE`: the initial size (in bytes) of a single GZip buffer. When zero, initializes empty GZip buffers. This makess sense only when GZip compression is enabled. Default: `0`
* `IMGPROXY_FREE_MEMORY_INTERVAL`: the interval (in seconds) at which unused memory will be returned to the OS. Default: `10`; * `IMGPROXY_FREE_MEMORY_INTERVAL`: the interval (in seconds) at which unused memory will be returned to the OS. Default: `10`
* `IMGPROXY_BUFFER_POOL_CALIBRATION_THRESHOLD`: the number of buffers that should be returned to a pool before calibration. Default: `1024`. * `IMGPROXY_BUFFER_POOL_CALIBRATION_THRESHOLD`: the number of buffers that should be returned to a pool before calibration. Default: `1024`
## Miscellaneous ## Miscellaneous
* `IMGPROXY_BASE_URL`: base URL prefix that will be added to every requested image URL. For example, if the base URL is `http://example.com/images` and `/path/to/image.png` is requested, imgproxy will download the source image from `http://example.com/images/path/to/image.png`. If the image URL already contains the prefix, it won't be added. Default: blank. * `IMGPROXY_BASE_URL`: a base URL prefix that will be added to each requested image URL. For example, if the base URL is `http://example.com/images` and `/path/to/image.png` is requested, imgproxy will download the source image from `http://example.com/images/path/to/image.png`. If the image URL already contains the prefix, it won't be added. Default: blank
* `IMGPROXY_USE_LINEAR_COLORSPACE`: when `true`, imgproxy will process images in linear colorspace. This will slow down processing. Note that images won't be fully processed in linear colorspace while shrink-on-load is enabled (see below). * `IMGPROXY_USE_LINEAR_COLORSPACE`: when `true`, imgproxy will process images in linear colorspace. This will slow down processing. Note that images won't be fully processed in linear colorspace while shrink-on-load is enabled (see below).
* `IMGPROXY_DISABLE_SHRINK_ON_LOAD`: when `true`, disables shrink-on-load for JPEG and WebP. Allows to process the whole image in linear colorspace but dramatically slows down resizing and increases memory usage when working with large images. * `IMGPROXY_DISABLE_SHRINK_ON_LOAD`: when `true`, disables shrink-on-load for JPEGs and WebP files. Allows processing the entire image in linear colorspace but dramatically slows down resizing and increases memory usage when working with large images.
* `IMGPROXY_STRIP_METADATA`: when `true`, imgproxy will strip all metadata (EXIF, IPTC, etc.) from JPEG and WebP output images. Default: `true`. * `IMGPROXY_STRIP_METADATA`: when `true`, imgproxy will strip all metadata (EXIF, IPTC, etc.) from JPEG and WebP output images. Default: `true`
* `IMGPROXY_STRIP_COLOR_PROFILE`: when `true`, imgproxy will transform the embedded color profile (ICC) to sRGB and remove it from the image. Otherwise, imgproxy will try to keep it as is. Default: `true`. * `IMGPROXY_STRIP_COLOR_PROFILE`: when `true`, imgproxy will transform the embedded color profile (ICC) to sRGB and remove it from the image. Otherwise, imgproxy will try to keep it as is. Default: `true`
* `IMGPROXY_AUTO_ROTATE`: when `true`, imgproxy will auto rotate images based on the EXIF Orientation parameter (if available in the image meta data). The orientation tag will be removed from the image anyway. Default: `true`. * `IMGPROXY_AUTO_ROTATE`: when `true`, imgproxy will automatically rotate images based on the EXIF Orientation parameter (if available in the image meta data). The orientation tag will be removed from the image in all cases. Default: `true`

View File

@ -2,26 +2,26 @@
imgproxy can send its metrics to Datadog. To use this feature, do the following: imgproxy can send its metrics to Datadog. To use this feature, do the following:
1. Install & configure the Datadog Trace Agent (>= 5.21.1); 1. Install & configure the Datadog Trace Agent (>= 5.21.1).
2. Set `IMGPROXY_DATADOG_ENABLE` environment variable to `true`; 2. Set the `IMGPROXY_DATADOG_ENABLE` environment variable to `true`.
3. Configure the Datadog tracer using `ENV` variables provided by [the package](https://github.com/DataDog/dd-trace-go): 3. Configure the Datadog tracer using `ENV` variables provided by [the package](https://github.com/DataDog/dd-trace-go):
* `DD_AGENT_HOST` sets the address to connect to for sending metrics to the Datadog Agent. Default: `localhost` * `DD_AGENT_HOST`: sets the address to connect to for sending metrics to the Datadog Agent. Default: `localhost`
* `DD_TRACE_AGENT_PORT` sets the Datadog Agent Trace port. Default: `8126` * `DD_TRACE_AGENT_PORT`: sets the Datadog Agent Trace port. Default: `8126`
* `DD_DOGSTATSD_PORT` set the DogStatsD port. Default: `8125` * `DD_DOGSTATSD_PORT`: set the DogStatsD port. Default: `8125`
* `DD_SERVICE` – sets desired application name. Default: `imgproxy` * `DD_SERVICE`: sets the desired application name. Default: `imgproxy`
* `DD_ENV` - sets the environment to which all traces will be submitted. Default: empty * `DD_ENV`: specifies the environment to which all traces will be submitted. Default: empty
* `DD_TRACE_SOURCE_HOSTNAME` - allows specifying the hostname with which to mark outgoing traces. Default: empty * `DD_TRACE_SOURCE_HOSTNAME`: specifies the hostname with which to mark outgoing traces. Default: empty
* `DD_TRACE_REPORT_HOSTNAME` - when `true`, sets hostname to `os.Hostname()` with which to mark outgoing traces. Default: `false` * `DD_TRACE_REPORT_HOSTNAME`: when `true`, sets hostname to `os.Hostname()` with which to mark outgoing traces. Default: `false`
* `DD_TAGS` - sets a key/value pair which will be set as a tag on all traces. Example: `DD_TAGS=datacenter:njc,key2:value2`. Default: empty * `DD_TAGS`: sets a key/value pair which will be set as a tag on all traces. Example: `DD_TAGS=datacenter:njc,key2:value2`. Default: empty
* `DD_TRACE_ANALYTICS_ENABLED` - allows specifying whether Trace Search & Analytics should be enabled for integrations. Default: `false` * `DD_TRACE_ANALYTICS_ENABLED`: allows specifying whether Trace Search & Analytics should be enabled for integrations. Default: `false`
* `DD_RUNTIME_METRICS_ENABLED` - enables automatic collection of runtime metrics every 10 seconds. Default: `false` * `DD_RUNTIME_METRICS_ENABLED`: enables automatic collection of runtime metrics every 10 seconds. Default: `false`
* `DD_TRACE_STARTUP_LOGS` causes various startup info to be written when the tracer starts. Default: `true` * `DD_TRACE_STARTUP_LOGS`: causes various startup info to be written when the tracer starts. Default: `true`
* `DD_TRACE_DEBUG` enables detailed logs. Default: `false` * `DD_TRACE_DEBUG`: enables detailed logs. Default: `false`
imgproxy will send the following info to Datadog: imgproxy will send the following info to Datadog:
* Response time; * Response time
* Image downloading time; * Image downloading time
* Image processing time; * Image processing time
* Errors that occurred while downloading and processing image. * Errors that occurred while downloading and processing image

View File

@ -11,19 +11,19 @@ Check out the [example](#example) at the end of this guide.
## Signature ## Signature
Signature protects your URL from being altered by an attacker. It is highly recommended to sign imgproxy URLs in production. A signature protects your URL from being altered by an attacker. It is highly recommended to sign imgproxy URLs when imgproxy is being used in production.
Once you set up your [URL signature](configuration.md#url-signature), check out the [Signing the URL](signing_the_url.md) guide to know how to sign your URLs. Otherwise, use any string here. Once you set up your [URL signature](configuration.md#url-signature), check out the [Signing the URL](signing_the_url.md) guide to find out how to sign your URLs. Otherwise, since the signature still needs to be present, feel free to use any string here.
## Processing options ## Processing options
Processing options should be specified as URL parts divided by slashes (`/`). Processing option has the following format: Processing options should be specified as URL parts divided by slashes (`/`). A processing option has the following format:
``` ```
%option_name:%argument1:%argument2:...:argumentN %option_name:%argument1:%argument2:...:argumentN
``` ```
The list of processing options does not define imgproxy's processing pipeline. Instead, imgproxy already comes with a specific, built-in image processing pipeline for the maximum performance. Read more about it in the [About processing pipeline](about_processing_pipeline.md) guide. The list of processing options does not define imgproxy's processing pipeline. Instead, imgproxy already comes with a specific, built-in image processing pipeline for maximum performance. Read more about this in the [About processing pipeline](about_processing_pipeline.md) guide.
imgproxy supports the following processing options: imgproxy supports the following processing options:
@ -34,7 +34,7 @@ resize:%resizing_type:%width:%height:%enlarge:%extend
rs:%resizing_type:%width:%height:%enlarge:%extend rs:%resizing_type:%width:%height:%enlarge:%extend
``` ```
Meta-option that defines the [resizing type](#resizing-type), [width](#width), [height](#height), [enlarge](#enlarge), and [extend](#extend). All arguments are optional and can be omitted to use their default values. This is a meta-option that defines the [resizing type](#resizing-type), [width](#width), [height](#height), [enlarge](#enlarge), and [extend](#extend). All arguments are optional and can be omitted to use their default values.
### Size ### Size
@ -43,7 +43,7 @@ size:%width:%height:%enlarge:%extend
s:%width:%height:%enlarge:%extend s:%width:%height:%enlarge:%extend
``` ```
Meta-option that defines the [width](#width), [height](#height), [enlarge](#enlarge), and [extend](#extend). All arguments are optional and can be omitted to use their default values. This is a meta-option that defines the [width](#width), [height](#height), [enlarge](#enlarge), and [extend](#extend). All arguments are optional and can be omitted to use their default values.
### Resizing type ### Resizing type
@ -54,10 +54,10 @@ rt:%resizing_type
Defines how imgproxy will resize the source image. Supported resizing types are: Defines how imgproxy will resize the source image. Supported resizing types are:
* `fit`: resizes the image while keeping aspect ratio to fit given size; * `fit`: resizes the image while keeping aspect ratio to fit a given size.
* `fill`: resizes the image while keeping aspect ratio to fill given size and cropping projecting parts; * `fill`: resizes the image while keeping aspect ratio to fill a given size and crops projecting parts.
* `fill-down`: <i class='badge badge-v3'></i> same as `fill`, but if the resized image is smaller than the requested size, imgproxy will crop the result to keep the requested aspect ratio; * `fill-down`: <i class='badge badge-v3'></i> the same as `fill`, but if the resized image is smaller than the requested size, imgproxy will crop the result to keep the requested aspect ratio.
* `force`: resizes the image without keeping aspect ratio; * `force`: resizes the image without keeping the aspect ratio.
* `auto`: if both source and resulting dimensions have the same orientation (portrait or landscape), imgproxy will use `fill`. Otherwise, it will use `fit`. * `auto`: if both source and resulting dimensions have the same orientation (portrait or landscape), imgproxy will use `fill`. Otherwise, it will use `fit`.
Default: `fit` Default: `fit`
@ -80,7 +80,7 @@ width:%width
w:%width w:%width
``` ```
Defines the width of the resulting image. When set to `0`, imgproxy will calculate the resulting width using the defined height and source aspect ratio. When set to `0` and rezizing type is `force`, imgproxy will keep the original width. Defines the width of the resulting image. When set to `0`, imgproxy will calculate width using the defined height and source aspect ratio. When set to `0` and rezizing type is `force`, imgproxy will keep the original width.
Default: `0` Default: `0`
@ -135,7 +135,7 @@ When set, imgproxy will multiply the image dimensions according to these factors
Can be combined with `width` and `height` options. In this case, imgproxy calculates scale factors for the provided size and then multiplies it with the provided zoom factors. Can be combined with `width` and `height` options. In this case, imgproxy calculates scale factors for the provided size and then multiplies it with the provided zoom factors.
**📝Note:** Unlike [dpr](#dpr), `zoom` doesn't set `Content-DPR` header in the response. **📝Note:** Unlike [dpr](#dpr), `zoom` doesn't set the `Content-DPR` header in the response.
Default: `1` Default: `1`
@ -147,7 +147,7 @@ dpr:%dpr
When set, imgproxy will multiply the image dimensions according to this factor for HiDPI (Retina) devices. The value must be greater than 0. When set, imgproxy will multiply the image dimensions according to this factor for HiDPI (Retina) devices. The value must be greater than 0.
**📝Note:** `dpr` also sets `Content-DPR` header in the response so the browser can render the image correctly. **📝Note:** `dpr` also sets the `Content-DPR` header in the response so the browser can correctly render the image.
Default: `1` Default: `1`
@ -160,7 +160,7 @@ el:%enlarge
When set to `1`, `t` or `true`, imgproxy will enlarge the image if it is smaller than the given size. When set to `1`, `t` or `true`, imgproxy will enlarge the image if it is smaller than the given size.
Default: false Default: `false`
### Extend ### Extend
@ -170,7 +170,7 @@ ex:%extend:%gravity
``` ```
* When `extend` is set to `1`, `t` or `true`, imgproxy will extend the image if it is smaller than the given size. * When `extend` is set to `1`, `t` or `true`, imgproxy will extend the image if it is smaller than the given size.
* `gravity` _(optional)_ accepts the same values as [gravity](#gravity) option, except `sm`. When `gravity` is not set, imgproxy will use `ce` gravity without offsets. * `gravity` _(optional)_ accepts the same values as the [gravity](#gravity) option, except `sm`. When `gravity` is not set, imgproxy will use `ce` gravity without offsets.
Default: `false:ce:0:0` Default: `false:ce:0:0`
@ -181,27 +181,27 @@ gravity:%type:%x_offset:%y_offset
g:%type:%x_offset:%y_offset g:%type:%x_offset:%y_offset
``` ```
When imgproxy needs to cut some parts of the image, it is guided by the gravity. When imgproxy needs to cut some parts of the image, it is guided by the gravity option.
* `type` - specifies the gravity type. Available values: * `type` - specifies the gravity type. Available values:
* `no`: north (top edge); * `no`: north (top edge)
* `so`: south (bottom edge); * `so`: south (bottom edge)
* `ea`: east (right edge); * `ea`: east (right edge)
* `we`: west (left edge); * `we`: west (left edge)
* `noea`: north-east (top-right corner); * `noea`: north-east (top-right corner)
* `nowe`: north-west (top-left corner); * `nowe`: north-west (top-left corner)
* `soea`: south-east (bottom-right corner); * `soea`: south-east (bottom-right corner)
* `sowe`: south-west (bottom-left corner); * `sowe`: south-west (bottom-left corner)
* `ce`: center. * `ce`: center
* `x_offset`, `y_offset` - (optional) specify gravity offset by X and Y axes. * `x_offset`, `y_offset` - (optional) specifies the gravity offset along the X and Y axes.
Default: `ce:0:0` Default: `ce:0:0`
**Special gravities**: **Special gravities**:
* `gravity:sm`: smart gravity. `libvips` detects the most "interesting" section of the image and considers it as the center of the resulting image. Offsets are not applicable here; * `gravity:sm`: smart gravity. `libvips` detects the most "interesting" section of the image and considers it as the center of the resulting image. Offsets are not applicable here.
* `gravity:obj:%class_name1:%class_name2:...:%class_nameN`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> object-oriented gravity. imgproxy [detects objects](object_detection.md) of provided classes on the image and calculates the resulting image center using their positions. If class names are omited, imgproxy will use all the detected objects. * `gravity:obj:%class_name1:%class_name2:...:%class_nameN`: <i class='badge badge-pro'></i> <i class='badge badge-v3'></i> object-oriented gravity. imgproxy [detects objects](object_detection.md) of provided classes on the image and calculates the resulting image center using their positions. If class names are omited, imgproxy will use all the detected objects.
* `gravity:fp:%x:%y`: focus point gravity. `x` and `y` are floating point numbers between 0 and 1 that define the coordinates of the center of the resulting image. Treat 0 and 1 as right/left for `x` and top/bottom for `y`. * `gravity:fp:%x:%y`: the gravity focus point . `x` and `y` are floating point numbers between 0 and 1 that define the coordinates of the center of the resulting image. Treat 0 and 1 as right/left for `x` and top/bottom for `y`.
### Crop ### Crop
@ -216,7 +216,7 @@ Defines an area of the image to be processed (crop before resize).
* When `width` or `height` is greater than or equal to `1`, imgproxy treats it as an absolute value. * When `width` or `height` is greater than or equal to `1`, imgproxy treats it as an absolute value.
* When `width` or `height` is less than `1`, imgproxy treats it as a relative value. * When `width` or `height` is less than `1`, imgproxy treats it as a relative value.
* When `width` or `height` is set to `0`, imgproxy will use the full width/height of the source image. * When `width` or `height` is set to `0`, imgproxy will use the full width/height of the source image.
* `gravity` _(optional)_ accepts the same values as [gravity](#gravity) option. When `gravity` is not set, imgproxy will use the value of the [gravity](#gravity) option. * `gravity` _(optional)_ accepts the same values as the [gravity](#gravity) option. When `gravity` is not set, imgproxy will use the value of the [gravity](#gravity) option.
### Trim ### Trim
@ -228,17 +228,17 @@ t:%threshold:%color:%equal_hor:%equal_ver
Removes surrounding background. Removes surrounding background.
* `threshold` - color similarity tolerance. * `threshold` - color similarity tolerance.
* `color` - _(optional)_ hex-coded value of the color that needs to be cut off. * `color` - _(optional)_ a hex-coded value of the color that needs to be cut off.
* `equal_hor` - _(optional)_ set to `1`, `t` or `true`, imgproxy will cut only equal parts from left and right sides. That means that if 10px of background can be cut off from left and 5px from right then 5px will be cut off from both sides. For example, it can be useful if objects on your images are centered but have non-symmetrical shadow. * `equal_hor` - _(optional)_ set to `1`, `t` or `true`, imgproxy will cut only equal parts from left and right sides. That means that if 10px of background can be cut off from the left and 5px from the right, then 5px will be cut off from both sides. For example, this can be useful if objects on your images are centered but have non-symmetrical shadow.
* `equal_ver` - _(optional)_ acts like `equal_hor` but for top/bottom sides. * `equal_ver` - _(optional)_ acts like `equal_hor` but for top/bottom sides.
**⚠️Warning:** Trimming requires an image to be fully loaded into memory. This disables scale-on-load and significantly increases memory usage and processing time. Use it carefully with large images. **⚠️Warning:** Trimming requires an image to be fully loaded into memory. This disables scale-on-load and significantly increases memory usage and processing time. Use it carefully with large images.
**📝Note:** If you know background color of your images then setting it explicitly via `color` will also save some resources because imgproxy won't detect it automatically. **📝Note:** If you know background color of your images then setting it explicitly via `color` will also save some resources because imgproxy won't need to automatically detect it.
**📝Note:** Use `color` value of `FF00FF` for trimming transparent background as imgproxy uses magenta as a transparency key. **📝Note:** Use a `color` value of `FF00FF` for trimming transparent backgrounds as imgproxy uses magenta as a transparency key.
**📝Note:** Trimming of animated images is not supported. **📝Note:** The trimming of animated images is not supported.
### Padding ### Padding
@ -247,16 +247,16 @@ padding:%top:%right:%bottom:%left
pd:%top:%right:%bottom:%left pd:%top:%right:%bottom:%left
``` ```
Defines padding size in css manner. All arguments are optional but at least one dimension must be set. Padded space is filled according to [background](#background) option. Defines padding size using CSS-style syntax. All arguments are optional but at least one dimension must be set. Padded space is filled according to the [background](#background) option.
* `top` - top padding (and all other sides if they won't be set explicitly); * `top` - top padding (and for all other sides if they haven't been explicitly st)
* `right` - right padding (and left if it won't be set explicitly); * `right` - right padding (and left if it hasn't been explicitly set)
* `bottom` - bottom padding; * `bottom` - bottom padding
* `left` - left padding. * `left` - left padding
**📝Note:** Padding is applied after all image transformations (except watermark) and enlarges generated image which means that if your resize dimensions were 100x200px and you applied `padding:10` option then you will get 120x220px image. **📝Note:** Padding is applied after all image transformations (except watermarking) and enlarges the generated image. This means that if your resize dimensions were 100x200px and you applied the `padding:10` option, then you will end up with an image with dimensions of 120x220px.
**📝Note:** Padding follows [dpr](#dpr) option so it will be scaled too if you set it. **📝Note:** Padding follows the [dpr](#dpr) option so it will also be scaled if you've set it.
### Auto Rotate ### Auto Rotate
@ -265,7 +265,7 @@ auto_rotate:%auto_rotate
ar:%auto_rotate ar:%auto_rotate
``` ```
When set to `1`, `t` or `true`, imgproxy will automatically rotate images based onon the EXIF Orientation parameter (if available in the image meta data). The orientation tag will be removed from the image anyway. Normally this is controlled by the [IMGPROXY_AUTO_ROTATE](configuration.md#miscellaneous) configuration but this procesing option allows the configuration to be set for each request. When set to `1`, `t` or `true`, imgproxy will automatically rotate images based on the EXIF Orientation parameter (if available in the image meta data). The orientation tag will be removed from the image in all cases. Normally this is controlled by the [IMGPROXY_AUTO_ROTATE](configuration.md#miscellaneous) configuration but this procesing option allows the configuration to be set for each request.
### Rotate ### Rotate
@ -276,7 +276,7 @@ rot:%angle
Rotates the image on the specified angle. The orientation from the image metadata is applied before the rotation unless autorotation is disabled. Rotates the image on the specified angle. The orientation from the image metadata is applied before the rotation unless autorotation is disabled.
**📝Note:** Only 0/90/180/270/etc degrees angles are supported. **📝Note:** Only 0, 90, 180, 270, etc., degree angles are supported.
Default: 0 Default: 0
@ -290,7 +290,7 @@ background:%hex_color
bg:%hex_color bg:%hex_color
``` ```
When set, imgproxy will fill the resulting image background with the specified color. `R`, `G`, and `B` are red, green and blue channel values of the background color (0-255). `hex_color` is a hex-coded value of the color. Useful when you convert an image with alpha-channel to JPEG. When set, imgproxy will fill the resulting image background with the specified color. `R`, `G`, and `B` are the red, green and blue channel values of the background color (0-255). `hex_color` is a hex-coded value of the color. Useful when you convert an image with alpha-channel to JPEG.
With no arguments provided, disables any background manipulations. With no arguments provided, disables any background manipulations.
@ -303,7 +303,7 @@ background_alpha:%alpha
bga:%alpha bga:%alpha
``` ```
Adds alpha channel to `background`. `alpha` is a positive floating point number between `0` and `1`. Adds an alpha channel to `background`. The value of `alpha` is a positive floating point number between `0` and `1`.
Default: 1 Default: 1
@ -314,7 +314,7 @@ adjust:%brightness:%contrast:%saturation
a:%brightness:%contrast:%saturation a:%brightness:%contrast:%saturation
``` ```
Meta-option that defines the [brightness](#brightness), [contrast](#contrast), and [saturation](#saturation). All arguments are optional and can be omitted to use their default values. This is a meta-option that defines the [brightness](#brightness), [contrast](#contrast), and [saturation](#saturation). All arguments are optional and can be omitted to use their default values.
### Brightness<i class='badge badge-pro'></i> :id=brightness ### Brightness<i class='badge badge-pro'></i> :id=brightness
@ -323,7 +323,7 @@ brightness:%brightness
br:%brightness br:%brightness
``` ```
When set, imgproxy will adjust brightness of the resulting image. `brightness` is an integer number in range from `-255` to `255`. When set, imgproxy will adjust brightness of the resulting image. `brightness` is an integer number ranging from `-255` to `255`.
Default: 0 Default: 0
@ -334,7 +334,7 @@ contrast:%contrast
co:%contrast co:%contrast
``` ```
When set, imgproxy will adjust contrast of the resulting image. `contrast` is a positive floating point number, where `1` keeps the contrast unchanged. When set, imgproxy will adjust the contrast of the resulting image. `contrast` is a positive floating point number, where a value of `1` leaves the contrast unchanged.
Default: 1 Default: 1
@ -345,7 +345,7 @@ saturation:%saturation
sa:%saturation sa:%saturation
``` ```
When set, imgproxy will adjust saturation of the resulting image. `saturation` is a positive floating point number, where `1` keeps the saturation unchanged. When set, imgproxy will adjust saturation of the resulting image. `saturation` is a positive floating-point number, where a value of `1` leaves the saturation unchanged.
Default: 1 Default: 1
@ -356,7 +356,7 @@ blur:%sigma
bl:%sigma bl:%sigma
``` ```
When set, imgproxy will apply the gaussian blur filter to the resulting image. `sigma` defines the size of a mask imgproxy will use. When set, imgproxy will apply a gaussian blur filter to the resulting image. The value of `sigma` defines the size of the mask imgproxy will use.
Default: disabled Default: disabled
@ -367,7 +367,7 @@ sharpen:%sigma
sh:%sigma sh:%sigma
``` ```
When set, imgproxy will apply the sharpen filter to the resulting image. `sigma` the size of a mask imgproxy will use. When set, imgproxy will apply the sharpen filter to the resulting image. The valoe of `sigma` defines the size of the mask imgproxy will use.
As an approximate guideline, use 0.5 sigma for 4 pixels/mm (display resolution), 1.0 for 12 pixels/mm and 1.5 for 16 pixels/mm (300 dpi == 12 pixels/mm). As an approximate guideline, use 0.5 sigma for 4 pixels/mm (display resolution), 1.0 for 12 pixels/mm and 1.5 for 16 pixels/mm (300 dpi == 12 pixels/mm).
@ -380,7 +380,7 @@ pixelate:%size
pix:%size pix:%size
``` ```
When set, imgproxy will apply the pixelate filter to the resulting image. `size` is the size of a pixel. When set, imgproxy will apply the pixelate filter to the resulting image. The value of `size` defines individual pixel size.
Default: disabled Default: disabled
@ -400,9 +400,9 @@ blur_detections:%sigma:%class_name1:%class_name2:...:%class_nameN
bd:%sigma:%class_name1:%class_name2:...:%class_nameN bd:%sigma:%class_name1:%class_name2:...:%class_nameN
``` ```
imgproxy [detects objects](object_detection.md) of provided classes and blus them. If class names are omitted, imgproxy blurs all the detected objects. imgproxy [detects objects](object_detection.md) of the provided classes and blurs them. If class names are omitted, imgproxy blurs all the detected objects.
`sigma` defines the size of a mask imgproxy will use. The value of `sigma` defines the size of the mask imgproxy will use.
### Draw detections<i class='badge badge-pro'></i><i class='badge badge-v3'></i> :id=draw-detections ### Draw detections<i class='badge badge-pro'></i><i class='badge badge-v3'></i> :id=draw-detections
@ -411,7 +411,7 @@ draw_detections:%draw:%class_name1:%class_name2:...:%class_nameN
dd:%draw:%class_name1:%class_name2:...:%class_nameN dd:%draw:%class_name1:%class_name2:...:%class_nameN
``` ```
When `draw` is set to `1`, `t` or `true`, imgproxy [detects objects](object_detection.md) of provided classes and draws their bounding boxed. If class names are omitted, imgproxy draws the bounding boxes of all the detected objects. When `draw` is set to `1`, `t` or `true`, imgproxy [detects objects](object_detection.md) of the provided classes and draws their bounding boxes. If class names are omitted, imgproxy draws the bounding boxes of all the detected objects.
### Watermark ### Watermark
@ -420,22 +420,22 @@ watermark:%opacity:%position:%x_offset:%y_offset:%scale
wm:%opacity:%position:%x_offset:%y_offset:%scale wm:%opacity:%position:%x_offset:%y_offset:%scale
``` ```
Puts watermark on the processed image. Places a watermark on the processed image.
* `opacity` - watermark opacity modifier. Final opacity is calculated like `base_opacity * opacity`. * `opacity`: watermark opacity modifier. Final opacity is calculated like `base_opacity * opacity`.
* `position` - (optional) specifies the position of the watermark. Available values: * `position`: (optional) specifies the position of the watermark. Available values:
* `ce`: (default) center; * `ce`: (default) center
* `no`: north (top edge); * `no`: north (top edge)
* `so`: south (bottom edge); * `so`: south (bottom edge)
* `ea`: east (right edge); * `ea`: east (right edge)
* `we`: west (left edge); * `we`: west (left edge)
* `noea`: north-east (top-right corner); * `noea`: north-east (top-right corner)
* `nowe`: north-west (top-left corner); * `nowe`: north-west (top-left corner)
* `soea`: south-east (bottom-right corner); * `soea`: south-east (bottom-right corner)
* `sowe`: south-west (bottom-left corner); * `sowe`: south-west (bottom-left corner)
* `re`: replicate watermark to fill the whole image; * `re`: repeat and tile the watermark to fill the entire image
* `x_offset`, `y_offset` - (optional) specify watermark offset by X and Y axes. For `re` position, define spacing between tiles; * `x_offset`, `y_offset` - (optional) specify watermark offset by X and Y axes. When using `re` position, these values define the spacing between the tiles.
* `scale` - (optional) floating point number that defines watermark size relative to the resulting image size. When set to `0` or omitted, watermark size won't be changed. * `scale`: (optional) a floating-point number that defines the watermark size relative to the resultant image size. When set to `0` or when omitted, the watermark size won't be changed.
Default: disabled Default: disabled
@ -446,7 +446,7 @@ watermark_url:%url
wmu:%url wmu:%url
``` ```
When set, imgproxy will use the image from the specified URL as a watermark. `url` is Base64-encoded URL of the custom watermark. When set, imgproxy will use the image from the specified URL as a watermark. `url` is the Base64-encoded URL of the custom watermark.
Default: blank Default: blank
@ -457,11 +457,11 @@ watermark_text:%text
wmt:%text wmt:%text
``` ```
When set, imgproxy will generate image from the provided text and use it as a watermark. `text` is Base64-encoded text of the custom watermark. When set, imgproxy will generate an image from the provided text and use it as a watermark. `text` is the Base64-encoded text of the custom watermark.
By default, text color is black and font is `sans 16`. You can use [Pango markup](https://docs.gtk.org/Pango/pango_markup.html) in the `text` value to change the style. By default, the text color is black and the font is `sans 16`. You can use [Pango markup](https://docs.gtk.org/Pango/pango_markup.html) in the `text` value to change the style.
If you want to use your custom font, you need to put it to `/usr/share/fonts` inside a contsainer. If you want to use a custom font, you need to put it in `/usr/share/fonts` inside a container.
Default: blank Default: blank
@ -472,7 +472,7 @@ style:%style
st:%style st:%style
``` ```
When set, imgproxy will prepend `<style>` node with provided content to the `<svg>` node of source SVG image. `%style` is url-safe Base64-encoded CSS-style. When set, imgproxy will prepend a `<style>` node with the provided content to the `<svg>` node of a source SVG image. `%style` is url-safe Base64-encoded CSS-styles.
Default: blank Default: blank
@ -483,7 +483,7 @@ strip_metadata:%strip_metadata
sm:%strip_metadata sm:%strip_metadata
``` ```
When set to `1`, `t` or `true`, imgproxy will strip the metadata (EXIF, IPTC, etc.) on JPEG and WebP output images. Normally this is controlled by the [IMGPROXY_STRIP_METADATA](configuration.md#miscellaneous) configuration but this procesing option allows the configuration to be set for each request. When set to `1`, `t` or `true`, imgproxy will strip the metadata (EXIF, IPTC, etc.) on JPEG and WebP output images. This is normally controlled by the [IMGPROXY_STRIP_METADATA](configuration.md#miscellaneous) configuration but this procesing option allows the configuration to be set for each request.
### Strip Color Profile ### Strip Color Profile
@ -492,7 +492,7 @@ strip_color_profile:%strip_color_profile
scp:%strip_color_profile scp:%strip_color_profile
``` ```
When set to `1`, `t` or `true`, imgproxy will transform the embedded color profile (ICC) to sRGB and remove it from the image. Otherwise, imgproxy will try to keep it as is. Normally this is controlled by the [IMGPROXY_STRIP_COLOR_PROFILE](configuration.md#miscellaneous) configuration but this procesing option allows the configuration to be set for each request. When set to `1`, `t` or `true`, imgproxy will transform the embedded color profile (ICC) to sRGB and remove it from the image. Otherwise, imgproxy will try to keep it as is. This is normally controlled by the [IMGPROXY_STRIP_COLOR_PROFILE](configuration.md#miscellaneous) configuration but this procesing option allows the configuration to be set for each request.
### Quality ### Quality
@ -501,7 +501,7 @@ quality:%quality
q:%quality q:%quality
``` ```
Redefines quality of the resulting image, percentage. When `0`, quality is assumed based on `IMGPROXY_QUALITY` and [format_quality](#format-quality). Redefines quality of the resulting image, as a percentage. When set to `0`, quality is assumed based on `IMGPROXY_QUALITY` and [format_quality](#format-quality).
Default: 0. Default: 0.
@ -532,11 +532,11 @@ max_bytes:%bytes
mb:%bytes mb:%bytes
``` ```
When set, imgproxy automatically degrades the quality of the image until the image is under the specified amount of bytes. When set, imgproxy automatically degrades the quality of the image until the image size is under the specified amount of bytes.
**📝Note:** Applicable only to `jpg`, `webp`, `heic`, and `tiff`. **📝Note:** Applicable only to `jpg`, `webp`, `heic`, and `tiff`.
**⚠️Warning:** When `max_bytes` is set, imgproxy saves image multiple times to achieve specified image size. **⚠️Warning:** When `max_bytes` is set, imgproxy saves image multiple times to achieve the specified image size.
Default: 0 Default: 0
@ -547,7 +547,7 @@ jpeg_options:%progressive:%no_subsample:%trellis_quant:%overshoot_deringing:%opt
jpgo:%progressive:%no_subsample:%trellis_quant:%overshoot_deringing:%optimize_scans:%quant_table jpgo:%progressive:%no_subsample:%trellis_quant:%overshoot_deringing:%optimize_scans:%quant_table
``` ```
Allows redefining JPEG saving options. All arguments have the same meaning as [Advanced JPEG compression](configuration.md#advanced-jpeg-compression) configs. All arguments are optional and can be omitted. Allows redefining JPEG saving options. All arguments have the same meaning as the [Advanced JPEG compression](configuration.md#advanced-jpeg-compression) configs. All arguments are optional and can be omitted.
### PNG options<i class='badge badge-pro'></i> :id=png-options ### PNG options<i class='badge badge-pro'></i> :id=png-options
@ -556,7 +556,7 @@ png_options:%interlaced:%quantize:%quantization_colors
pngo:%interlaced:%quantize:%quantization_colors pngo:%interlaced:%quantize:%quantization_colors
``` ```
Allows redefining PNG saving options. All arguments have the same meaning as [Advanced PNG compression](configuration.md#advanced-png-compression) configs. All arguments are optional and can be omitted. Allows redefining PNG saving options. All arguments have the same meaning as with the [Advanced PNG compression](configuration.md#advanced-png-compression) configs. All arguments are optional and can be omitted.
### GIF options<i class='badge badge-pro'></i> :id=gif-options ### GIF options<i class='badge badge-pro'></i> :id=gif-options
@ -565,7 +565,7 @@ gif_options:%optimize_frames:%optimize_transparency
gifo:%optimize_frames:%optimize_transparency gifo:%optimize_frames:%optimize_transparency
``` ```
Allows redefining GIF saving options. All arguments have the same meaning as [Advanced GIF compression](configuration.md#advanced-gif-compression) configs. All arguments are optional and can be omitted. Allows redefining GIF saving options. All arguments have the same meaning as with the [Advanced GIF compression](configuration.md#advanced-gif-compression) configs. All arguments are optional and can be omitted.
### Format ### Format
@ -575,7 +575,7 @@ f:%extension
ext:%extension ext:%extension
``` ```
Specifies the resulting image format. Alias for [extension](#extension) URL part. Specifies the resulting image format. Alias for the [extension](#extension) part of the URL.
Default: `jpg` Default: `jpg`
@ -586,7 +586,7 @@ page:%page
pg:%page pg:%page
``` ```
When source image supports pagination (PDF, TIFF) or animation (GIF, WebP), this option allows specifying the page to use. Pages numeration starts from zero. When a source image supports pagination (PDF, TIFF) or animation (GIF, WebP), this option allows specifying the page to use it on. Page numeration starts from zero.
Default: 0 Default: 0
@ -601,14 +601,14 @@ Allows redefining `IMGPROXY_VIDEO_THUMBNAIL_SECOND` config.
### Fallback image URL<i class='badge badge-pro'></i><i class='badge badge-v3'></i> :id=fallback-image-url ### Fallback image URL<i class='badge badge-pro'></i><i class='badge badge-v3'></i> :id=fallback-image-url
You can use a custom fallback image specifying its URL with `fallback_image_url` processing option: You can use a custom fallback image by specifying its URL with the `fallback_image_url` processing option:
``` ```
fallback_image_url:%url fallback_image_url:%url
fiu:%url fiu:%url
``` ```
Where `url` is Base64-encoded URL of the custom fallback image. The value of `url` is the Base64-encoded URL of the custom fallback image.
Default: blank Default: blank
@ -619,9 +619,9 @@ skip_processing:%extension1:%extension2:...:%extensionN
skp:%extension1:%extension2:...:%extensionN skp:%extension1:%extension2:...:%extensionN
``` ```
When set, imgproxy will skip the processing of listed formats. Also available as [IMGPROXY_SKIP_PROCESSING_FORMATS](configuration.md#skip-processing) configuration. When set, imgproxy will skip the processing of the listed formats. Also available as the [IMGPROXY_SKIP_PROCESSING_FORMATS](configuration.md#skip-processing) configuration.
**📝Note:** Processing can be skipped only when the requested format is the same as the source format. **📝Note:** Processing can only be skipped when the requested format is the same as the source format.
**📝Note:** Video thumbnail processing can't be skipped. **📝Note:** Video thumbnail processing can't be skipped.
@ -634,9 +634,9 @@ cachebuster:%string
cb:%string cb:%string
``` ```
Cache buster doesn't affect image processing but it's changing allows to bypass CDN, proxy server and browser cache. Useful when you have changed some things that are not reflected in the URL like image quality settings, presets or watermark data. Cache buster doesn't affect image processing but it's changing allows for bypassing the CDN, proxy server and browser cache. Useful when you have changed some things that are not reflected in the URL, like image quality settings, presets, or watermark data.
It's highly recommended to prefer `cachebuster` option over URL query string because the option can be properly signed. It's highly recommended to prefer the `cachebuster` option over a URL query string because that option can be properly signed.
Default: empty Default: empty
@ -647,7 +647,7 @@ expires:%timestamp
exp:%timestamp exp:%timestamp
``` ```
When set, imgproxy will check provided unix timestamp and return 404 when expired. When set, imgproxy will check the provided unix timestamp and return 404 when expired.
Default: empty Default: empty
@ -658,7 +658,7 @@ filename:%string
fn:%string fn:%string
``` ```
Defines a filename for `Content-Disposition` header. When not specified, imgproxy will get filename from the source url. Defines a filename for the `Content-Disposition` header. When not specified, imgproxy will get the filename from the source url.
Default: empty Default: empty
@ -677,19 +677,19 @@ Default: empty
## Source URL ## Source URL
There are two ways to specify source url: There are two ways to specify the source url:
### Plain ### Plain
The source URL can be provided as is, prendended by `/plain/` part: The source URL can be provided as is, prendended by the `/plain/` segment:
``` ```
/plain/http://example.com/images/curiosity.jpg /plain/http://example.com/images/curiosity.jpg
``` ```
**📝Note:** If the source URL contains query string or `@`, you need to escape it. **📝Note:** If the source URL contains a query string or `@`, you'll need to escape it.
When using plain source URL, you can specify the [extension](#extension) after `@`: When using a plain source URL, you can specify the [extension](#extension) after `@`:
``` ```
/plain/http://example.com/images/curiosity.jpg@png /plain/http://example.com/images/curiosity.jpg@png
@ -697,13 +697,13 @@ When using plain source URL, you can specify the [extension](#extension) after `
### Base64 encoded ### Base64 encoded
The source URL can be encoded with URL-safe Base64. The encoded URL can be split with `/` for your needs: The source URL can be encoded with URL-safe Base64. The encoded URL can be split with `/` as desired:
``` ```
/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn /aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn
``` ```
When using encoded source URL, you can specify the [extension](#extension) after `.`: When using an encoded source URL, you can specify the [extension](#extension) after `.`:
``` ```
/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png /aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
@ -711,13 +711,13 @@ When using encoded source URL, you can specify the [extension](#extension) after
## Extension ## Extension
Extension specifies the format of the resulting image. Read about image formats support [here](image_formats_support.md). Extension specifies the format of the resulting image. Read more about image formats support [here](image_formats_support.md).
The extension part can be omitted. In this case, imgproxy will use source image format as resulting one. If source image format is not supported as resulting, imgproxy will use `jpg`. You also can [enable WebP support detection](configuration.md#webp-support-detection) to use it as default resulting format when possible. The extension can be omitted. In this case, imgproxy will use the source image format as resulting one. If the source image format is not supported as the resulting image, imgproxy will use `jpg`. You also can [enable WebP support detection](configuration.md#webp-support-detection) to use it as the default resulting format when possible.
## Example ## Example
Signed imgproxy URL that uses `sharp` preset, resizes `http://example.com/images/curiosity.jpg` to fill `300x400` area with smart gravity without enlarging, and then converts the image to `png`: A signed imgproxy URL that uses the `sharp` preset, resizes `http://example.com/images/curiosity.jpg` to fill a `300x400` area using smart gravity without enlarging, and then converts the image to `png`:
``` ```
http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/preset:sharp/resize:fill:300:400:0/gravity:sm/plain/http://example.com/images/curiosity.jpg@png http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/preset:sharp/resize:fill:300:400:0/gravity:sm/plain/http://example.com/images/curiosity.jpg@png
@ -729,7 +729,7 @@ The same URL with shortcuts will look like this:
http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/pr:sharp/rs:fill:300:400:0/g:sm/plain/http://example.com/images/curiosity.jpg@png http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/pr:sharp/rs:fill:300:400:0/g:sm/plain/http://example.com/images/curiosity.jpg@png
``` ```
The same URL with Base64-encoded source URL will look like this: The same URL with a Base64-encoded source URL will look like this:
``` ```
http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/pr:sharp/rs:fill:300:400:0/g:sm/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/pr:sharp/rs:fill:300:400:0/g:sm/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png

View File

@ -1,6 +1,6 @@
# Getting the image info<i class='badge badge-pro'></i> # Getting the image info<i class='badge badge-pro'></i>
imgproxy can fetch and return the source image info without downloading the whole image. imgproxy can fetch and return a source image info without downloading the whole image.
## URL format ## URL format
@ -13,9 +13,9 @@ To get the image info, use the following URL format:
### Signature ### Signature
Signature protects your URL from being modified by an attacker. It is highly recommended to sign imgproxy URLs in a production environment. A signature protects your URL from being modified by an attacker. It is highly recommended to sign imgproxy URLs in a production environment.
Once you set up your [URL signature](configuration.md#url-signature), check out the [Signing the URL](signing_the_url.md) guide to learn about how to sign your URLs. Otherwise, use any string here. Once you set up your [URL signature](configuration.md#url-signature), check out the [Signing the URL](signing_the_url.md) guide to learn about how to sign your URLs. Otherwise, since the signature is required, feel free to use any string here.
### Source URL ### Source URL
@ -29,11 +29,11 @@ The source URL can be provided as is, prepended by `/plain/` part:
/plain/http://example.com/images/curiosity.jpg /plain/http://example.com/images/curiosity.jpg
``` ```
**📝Note:** If the source URL contains query string or `@`, you need to escape it. **📝Note:** If the source URL contains a query string or `@`, you'll need to escape it.
#### Base64 encoded #### Base64 encoded
The source URL can be encoded with URL-safe Base64. The encoded URL can be split with `/` for your needs: The source URL can be encoded with URL-safe Base64. The encoded URL can be split with `/` as desired:
``` ```
/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn /aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn
@ -41,15 +41,15 @@ The source URL can be encoded with URL-safe Base64. The encoded URL can be split
## Response format ## Response format
imgproxy responses with JSON body and returns the following info: imgproxy responses with a JSON body and returns the following info:
* `format`: source image/video format. In case of video - list of predicted formats divided by comma; * `format`: source image/video format. In case of video - list of predicted formats divided by comma
* `width`: image/video width; * `width`: image/video width
* `height`: image/video height; * `height`: image/video height
* `size`: file size. Can be zero if the image source doesn't set `Content-Length` header properly; * `size`: file size. Can be zero if the image source doesn't set `Content-Length` header properly
* `exif`: Exif data; * `exif`: Exif data
* `iptc`: IPTC data; * `iptc`: IPTC data
* `video_meta`: metadata from the video. * `video_meta`: metadata from the video
**📝Note:** There are lots of IPTC tags in the spec, but imgproxy supports only a few of them. If you need some tags to be supported, just contact us. **📝Note:** There are lots of IPTC tags in the spec, but imgproxy supports only a few of them. If you need some tags to be supported, just contact us.

View File

@ -2,13 +2,13 @@
imgproxy comes with a built-in health check HTTP endpoint at `/health`. imgproxy comes with a built-in health check HTTP endpoint at `/health`.
`GET /health` returns HTTP Status `200 OK` if the server is started successfully. `GET /health` returns an HTTP Status of `200 OK` if the server has been successfully started.
You can use this for readiness/liveness probe when deploying with a container orchestration system such as Kubernetes. You can use this for readiness/liveness probes when deploying with a container orchestration system such as Kubernetes.
## imgproxy health ## imgproxy health
imgproxy provides `imgproxy health` command that makes an HTTP request to the health endpoint based on `IMGPROXY_BIND` and `IMGPROXY_NETWORK` configs. It exits with `0` when the request is successful and with `1` otherwise. The command is handy to use with Docker Compose: imgproxy provides an `imgproxy health` command that makes an HTTP request to the health endpoint based on the `IMGPROXY_BIND` and `IMGPROXY_NETWORK` configs. It exits with `0` when the request is successful and with `1` otherwise. The command is handy to use with Docker Compose:
```yaml ```yaml
healthcheck: healthcheck:

View File

@ -18,57 +18,35 @@ At the moment, imgproxy supports only the most popular image formats:
| MP4 (h264)<i class='badge badge-pro'></i> | `mp4` | [See notes](#video-thumbnails) | Yes | | MP4 (h264)<i class='badge badge-pro'></i> | `mp4` | [See notes](#video-thumbnails) | Yes |
| Other video formats<i class='badge badge-pro'></i> | | [See notes](#video-thumbnails) | No | | Other video formats<i class='badge badge-pro'></i> | | [See notes](#video-thumbnails) | No |
## GIF support
imgproxy supports GIF output only when using libvips 8.7.0+ compiled with ImageMagick support. Official imgproxy Docker image supports GIF out of the box.
## ICO support
imgproxy supports ICO only when using libvips 8.7.0+ compiled with ImageMagick support. Official imgproxy Docker image supports ICO out of the box.
## SVG support ## SVG support
imgproxy supports SVG sources without limitations, but SVG results are not supported when the source image is not SVG. imgproxy supports SVG sources without limitations, but SVG results are not supported when the source image is not SVG.
When the source image is SVG and the SVG result is requested, imgproxy returns source image without modifications. When the source image is SVG and an SVG result is requested, imgproxy returns the source image without modifications.
imgproxy reads some amount of bytes to check if the source image is SVG. By default it reads maximum of 32KB, but you can change this: 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:
* `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) * `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)
## HEIC support
imgproxy supports HEIC only when using libvips 8.8.0+. Official imgproxy Docker image supports HEIC out of the box.
## AVIF support
imgproxy supports AVIF only when using libvips 8.9.0+ with compiled support for libheif + its supported encoder (rav1e, aom). Official imgproxy Docker image supports AVIF out of the box.
## BMP support
imgproxy supports BMP only when using libvips 8.7.0+ compiled with ImageMagick support. Official imgproxy Docker image supports ICO out of the box.
By default, imgproxy saves BMP images as JPEG. You need to explicitly specify the `format` option to get BMP output.
## Animated images support ## Animated images support
Since processing of animated images is pretty heavy, only one frame is processed by default. You can increase the maximum of animation frames to process with the following variable: 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:
* `IMGPROXY_MAX_ANIMATION_FRAMES`: the maximum of animated image frames to being processed. Default: `1`. * `IMGPROXY_MAX_ANIMATION_FRAMES`: the maximum of animated image frames to be processed. Default: `1`.
**📝Note:** imgproxy summarizes all frames resolutions while checking source image resolution. **📝Note:** imgproxy summarizes all frames resolutions while the checking source image resolution.
## Converting animated images to MP4<i class='badge badge-pro'></i> :id=converting-animated-images-to-mp4 ## Converting animated images to MP4<i class='badge badge-pro'></i> :id=converting-animated-images-to-mp4
Animated images results can be converted to MP4 by specifying `mp4` extension. Animated image results can be converted to MP4 by specifying the `mp4` extension.
Since MP4 requires usage of a `<video>` tag instead of `<img>`, automatic conversion to MP4 is not provided. Since MP4 requires use of a `<video>` tag instead of `<img>`, automatic conversion to MP4 is not provided.
## Video thumbnails<i class='badge badge-pro'></i> :id=video-thumbnails ## Video thumbnails<i class='badge badge-pro'></i> :id=video-thumbnails
If you provide a video as a source, imgproxy takes its specific frame to create a thumbnail. Doing this imgproxy downloads only the amount of data required to reach the needed frame. If you provide a video as a source, imgproxy takes a specific frame to create a thumbnail. To do this, imgproxy downloads only the amount of data required to reach the needed frame.
Since this still requires more data to be downloaded, video thumbnails generation is disabled by default and should be enabled with `IMGPROXY_ENABLE_VIDEO_THUMBNAILS` config option. Since this still requires more data to be downloaded, video thumbnail generation is disabled by default and should be enabled with `IMGPROXY_ENABLE_VIDEO_THUMBNAILS` config option.
* `IMGPROXY_ENABLE_VIDEO_THUMBNAILS`: when true, enables video thumbnails generation. Default: false; * `IMGPROXY_ENABLE_VIDEO_THUMBNAILS`: when true, enables video thumbnail generation. Default: `false`
* `IMGPROXY_VIDEO_THUMBNAIL_SECOND`: the timestamp of the frame in seconds that will be used for a thumbnail. Default: 1. * `IMGPROXY_VIDEO_THUMBNAIL_SECOND`: the timestamp of the frame (in seconds) that will be used for the thumbnail. Default: 1.

View File

@ -4,14 +4,14 @@ There are four ways you can install imgproxy:
## Docker ## Docker
imgproxy can (and should) be used as a standalone application inside a Docker container. Just pull the official image from Docker Hub: imgproxy can (and this is highly recommended) be used as a standalone application inside a Docker container. Just pull the official image from Docker Hub:
```bash ```bash
docker pull darthsim/imgproxy:latest docker pull darthsim/imgproxy:latest
docker run -p 8080:8080 -it darthsim/imgproxy docker run -p 8080:8080 -it darthsim/imgproxy
``` ```
You can also build your own image. imgproxy is ready to be dockerized, plug and play: You can also build your own image. imgproxy is ready to be dockerized out of the box:
```bash ```bash
docker build -f docker/Dockerfile -t imgproxy . docker build -f docker/Dockerfile -t imgproxy .
@ -32,15 +32,15 @@ helm upgrade -i imgproxy imgproxy/imgproxy
helm upgrade -i --name imgproxy imgproxy/imgproxy helm upgrade -i --name imgproxy imgproxy/imgproxy
``` ```
Read the [chart's README](https://github.com/imgproxy/imgproxy-helm) for more info. Check out the [chart's README](https://github.com/imgproxy/imgproxy-helm) for more info.
## Heroku ## Heroku
imgproxy can be deployed to Heroku with a click of a button: imgproxy can be deployed to Heroku with the click of a button:
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/imgproxy/imgproxy) [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/imgproxy/imgproxy)
However, you can do it manually with a few steps: That being said, you can also do it manually in just a few steps:
```bash ```bash
git clone https://github.com/imgproxy/imgproxy.git && cd imgproxy git clone https://github.com/imgproxy/imgproxy.git && cd imgproxy
@ -64,7 +64,7 @@ brew install imgproxy
## From the source ## From the source
You can get imgproxy source by cloning the GitHub repo: You can get the imgproxy source code by cloning the GitHub repo:
```bash ```bash
git clone https://github.com/imgproxy/imgproxy.git git clone https://github.com/imgproxy/imgproxy.git
@ -80,7 +80,7 @@ curl -Ls https://github.com/imgproxy/imgproxy/archive/master.tar.gz \
| tar -xz --strip-components 1 -C . | tar -xz --strip-components 1 -C .
``` ```
You can also download the specific version: You can also download a specific version:
```bash ```bash
mkdir imgproxy mkdir imgproxy
@ -93,7 +93,7 @@ curl -Ls https://github.com/imgproxy/imgproxy/archive/v2.13.1.tar.gz \
First, install [libvips](https://github.com/libvips/libvips). First, install [libvips](https://github.com/libvips/libvips).
Ubuntu apt repository contains a pretty old version of libvips. You can use PPA with more recent version of libvips: The Ubuntu apt repository contains a pretty old version of libvips. You can use PPA to access a more recent version of libvips:
```bash ```bash
sudo add-apt-repository ppa:dhor/myway sudo add-apt-repository ppa:dhor/myway
@ -103,7 +103,7 @@ sudo apt-get install libvips-dev
But if you want to use all the features of imgproxy, it's recommended to build libvips from the source: [https://github.com/libvips/ libvips/wiki/Build-for-Ubuntu](https://github.com/libvips/libvips/wiki/Build-for-Ubuntu) But if you want to use all the features of imgproxy, it's recommended to build libvips from the source: [https://github.com/libvips/ libvips/wiki/Build-for-Ubuntu](https://github.com/libvips/libvips/wiki/Build-for-Ubuntu)
Next, install the latest Go: Next, install the latest version of Go:
```bash ```bash
sudo add-apt-repository ppa:longsleep/golang-backports sudo add-apt-repository ppa:longsleep/golang-backports

View File

@ -1,24 +1,24 @@
# Memory usage tweaks # Memory usage tweaks
There are some imgproxy options that can help you to optimize memory usage and decrease memory fragmentation. There are some imgproxy options that can help you optimize memory usage and decrease memory fragmentation.
**⚠️Warning:** This is an advanced part. Please make sure that you know what you're doing before changing anything. **⚠️Warning:** This is an advanced part. Please make sure that you know what you're doing before changing anything.
### IMGPROXY_DOWNLOAD_BUFFER_SIZE ### IMGPROXY_DOWNLOAD_BUFFER_SIZE
imgproxy uses memory buffers to download source images. While these buffers are empty at the start by default, they can grow to a required size when imgproxy downloads an image. Allocating new memory to grow the buffers can cause memory fragmentation. Allocating required memory at the start can eliminate much of memory fragmentation since buffers won't grow. Setting `IMGPROXY_DOWNLOAD_BUFFER_SIZE` will tell imgproxy to initialize download buffers with _at least_ the specified size. It's recommended to use the estimated 95 percentile of your image sizes as the initial download buffers size. imgproxy uses memory buffers to download source images. While these buffers are empty at the beginning by default, they can grow to a required size when imgproxy downloads an image. Allocating new memory to grow the buffers can cause memory fragmentation. Allocating the required memory at the beginning can eliminate much of memory fragmentation since the buffers won't grow. Setting `IMGPROXY_DOWNLOAD_BUFFER_SIZE` will tell imgproxy to initialize download buffers with _at least_ the specified size. It's recommended to use the estimated 95 percentile of your image sizes as the initial download buffers size.
### IMGPROXY_FREE_MEMORY_INTERVAL ### IMGPROXY_FREE_MEMORY_INTERVAL
Working with a large amount of data can cause allocating some memory that is not used most of the time. That's why imgproxy enforces Go's garbage collector to free as much memory as possible and return it to the OS. The default interval of this action is 10 seconds, but you can change it by setting `IMGPROXY_FREE_MEMORY_INTERVAL`. Decreasing the interval can smooth the memory usage graph but it can also slow down imgproxy a little. Increasing has the opposite effect. Working with a large amount of data can result in allocating some memory that is generally not used. That's why imgproxy enforces Go's garbage collector to free as much memory as possible and return it to the OS. The default interval of this action is 10 seconds, but you can change it by setting `IMGPROXY_FREE_MEMORY_INTERVAL`. Decreasing the interval can smooth out the memory usage graph but it can also slow down imgproxy a little. Increasing it has the opposite effect.
### IMGPROXY_BUFFER_POOL_CALIBRATION_THRESHOLD ### IMGPROXY_BUFFER_POOL_CALIBRATION_THRESHOLD
Buffer pools in imgproxy do self-calibration time by time. imgproxy collects stats about the sizes of the buffers returned to a pool and calculates the default buffer size and the maximum size of a buffer that can be returned to the pool. This allows dropping buffers that are too big for most of the images and save some memory. By default, imgproxy starts calibration after 1024 buffers were returned to a pool. You can change this number with `IMGPROXY_BUFFER_POOL_CALIBRATION_THRESHOLD` variable. Increasing the number will give you rarer but more accurate calibration. Buffer pools in imgproxy do self-calibration time by time. imgproxy collects stats about the sizes of the buffers returned to a pool and calculates the default buffer size and the maximum size of a buffer that can be returned to the pool. This allows dropping buffers that are too big for most of the images and helps save some memory. By default, imgproxy starts calibration after 1024 buffers have been returned to a pool. You can change this number with the `IMGPROXY_BUFFER_POOL_CALIBRATION_THRESHOLD` variable. Increasing the number will give you rarer but more accurate calibration.
### MALLOC_ARENA_MAX ### MALLOC_ARENA_MAX
`libvips` uses GLib for memory management, and it brings GLib memory fragmentation issues to heavily multi-threaded programs. imgproxy is definitely one of them. First thing you can try if you noticed constantly growing RSS usage without Go's sys memory growth is set `MALLOC_ARENA_MAX`: `libvips` uses GLib for memory management, and it brings with it GLib memory fragmentation issues to heavily multi-threaded programs. And imgproxy is definitely one of these. First thing you can try if you noticed constantly growing RSS usage without Go's sys memory growth is set `MALLOC_ARENA_MAX`:
``` ```
MALLOC_ARENA_MAX=2 imgproxy MALLOC_ARENA_MAX=2 imgproxy
@ -33,7 +33,7 @@ If setting `MALLOC_ARENA_MAX` doesn't show you satisfying results, it's time to
> jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. > jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support.
Most Linux distributives provide their jemalloc packages. Using jemalloc doesn't require rebuilding imgproxy or it's dependencies and can be enabled by `LD_PRELOAD` environment variable. See Debian example below. Note that jemalloc library path may vary in your system. Most Linux distributives provide their jemalloc packages. Using jemalloc doesn't require rebuilding imgproxy or it's dependencies and can be enabled by the `LD_PRELOAD` environment variable. See the example with Debian below. Note that jemalloc library path may vary on your system.
``` ```
sudo apt-get install libjemalloc1 sudo apt-get install libjemalloc1

View File

@ -2,14 +2,14 @@
imgproxy can send its metrics to New Relic. To use this feature, do the following: imgproxy can send its metrics to New Relic. To use this feature, do the following:
1. Register at New Relic to get license key; 1. Register at New Relic and get a license key.
2. Set `IMGPROXY_NEW_RELIC_KEY` environment variable to the license key; 2. Set the `IMGPROXY_NEW_RELIC_KEY` environment variable to the license key.
3. _(optional)_ Set `IMGPROXY_NEW_RELIC_APP_NAME` environment variable to the desired application name. 3. _(optional)_ Set the `IMGPROXY_NEW_RELIC_APP_NAME` environment variable to be the desired application name.
imgproxy will send the following info to New Relic: imgproxy will send the following info to New Relic:
* CPU and memory usage; * CPU and memory usage
* Response time; * Response time
* Image downloading time; * Image downloading time
* Image processing time; * Image processing time
* Errors that occurred while downloading and processing image. * Errors that occurred while downloading and processing an image

View File

@ -1,19 +1,19 @@
# Object detection<i class='badge badge-pro'></i><i class='badge badge-v3'></i> # Object detection<i class='badge badge-pro'></i><i class='badge badge-v3'></i>
imgproxy can detect objects on the image and use them for smart crop, bluring the detections, or drawing the detections. imgproxy can detect objects on the image and use them for smart cropping, bluring the detections, or drawing the detections.
For object detection purposes, imgproxy uses [Darknet YOLO](https://github.com/AlexeyAB/darknet) model. We provide Docker images with a model trained for face detection, but you can use any Darknet YOLO model found in the [zoo](https://github.com/AlexeyAB/darknet/wiki/YOLOv4-model-zoo) or you can train your own model following the [guide](https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects). For object detection purposes, imgproxy uses the [Darknet YOLO](https://github.com/AlexeyAB/darknet) model. We provide Docker images with a model trained for face detection, but you can use any Darknet YOLO model found in the [zoo](https://github.com/AlexeyAB/darknet/wiki/YOLOv4-model-zoo) or you can train your own model by following this [guide](https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects).
## Configuration ## Configuration
You need to define four config variables to enable object detection: You need to define four config variables to enable object detection:
* `IMGPROXY_OBJECT_DETECTION_CONFIG`: path to the neural network config. * `IMGPROXY_OBJECT_DETECTION_CONFIG`: a path to the neural network config
* `IMGPROXY_OBJECT_DETECTION_WEIGHTS`: path to the neural network weights. * `IMGPROXY_OBJECT_DETECTION_WEIGHTS`: a path to the neural network weights
* `IMGPROXY_OBJECT_DETECTION_CLASSES`: path to the text file with the classes names, one by line. * `IMGPROXY_OBJECT_DETECTION_CLASSES`: a path to the text file with the classes names, one per line
* `IMGPROXY_OBJECT_DETECTION_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: 416. * `IMGPROXY_OBJECT_DETECTION_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: 416
Read the [configuration](configuration.md#object-detection) guide for more config values info. Read the [configuration guide](configuration.md#object-detection) for more config values info.
## Usage examples ## Usage examples
### Object-oriented crop ### Object-oriented crop
@ -26,7 +26,7 @@ You can [crop](https://docs.imgproxy.net/generating_the_url?id=crop) your images
### Bluring detections ### Bluring detections
You can [blur objects](https://docs.imgproxy.net/generating_the_url?id=blur-detections) of desired classes for anonymization or hiding NSFW content: You can [blur objects](https://docs.imgproxy.net/generating_the_url?id=blur-detections) of desired classes, thus making anonymization or hiding NSFW content possible:
``` ```
.../blur_detections:7:face/... .../blur_detections:7:face/...
@ -34,7 +34,7 @@ You can [blur objects](https://docs.imgproxy.net/generating_the_url?id=blur-dete
### Draw detections ### Draw detections
You can make imgproxy [draw bounding boxes](https://docs.imgproxy.net/generating_the_url?id=draw-detections) of detected objects of desired classes (handy for testing your models): You can make imgproxy [draw bounding boxes](https://docs.imgproxy.net/generating_the_url?id=draw-detections) for the detected objects of the desired classes (this is handy for testing your models):
``` ```
.../draw_detections:1:face/... .../draw_detections:1:face/...

View File

@ -1,16 +1,16 @@
# Presets # Presets
imgproxy preset is a named set of processing options. Presets can be used in [URLs](generating_the_url.md#preset) to make them shorter and somewhat readable. An imgproxy preset is a named set of processing options. Presets can be used in [URLs](generating_the_url.md#preset) to make shorter and more human-readable.
## Presets definition ## Presets definition
The preset definition looks like this: A preset definition looks like this:
``` ```
%preset_name=%processing_options %preset_name=%processing_options
``` ```
Processing options should be defined in the same way as you define them in the [URLs](generating_the_url.md#processing-options). For example, here is a preset named `awesome` that sets the resizing type to `fill` and resulting format to `jpg`: Processing options should be defined in the same way they are defined in [URLs](generating_the_url.md#processing-options). For example, here's a preset named `awesome` that sets the resizing type to `fill` and the resulting format to `jpg`:
``` ```
awesome=resizing_type:fill/format:jpg awesome=resizing_type:fill/format:jpg
@ -20,11 +20,11 @@ Read how to specify your presets with imgproxy in the [Configuration](configurat
## Default preset ## Default preset
A preset named `default` will be applied to each image. Useful in case you want your default processing options to be different from the imgproxy default ones. A preset named `default` will be applied to each image. This is useful when you want your default processing options to be different from the default imgproxy options.
## Only presets ## Only presets
Setting `IMGPROXY_ONLY_PRESETS` as `true` switches imgproxy into "presets-only mode". In this mode imgproxy accepts presets list as processing options just like you'd specify them for the `preset` option: Setting `IMGPROXY_ONLY_PRESETS` to `true` switches imgproxy into "presets-only mode". In this mode, imgproxy accepts a presets list as processing options just like you'd specify them for the `preset` option:
``` ```
http://imgproxy.example.com/unsafe/thumbnail:blurry:watermarked/plain/http://example.com/images/curiosity.jpg@png http://imgproxy.example.com/unsafe/thumbnail:blurry:watermarked/plain/http://example.com/images/curiosity.jpg@png

View File

@ -1,23 +1,22 @@
# Prometheus # Prometheus
imgproxy can collect its metrics for Prometheus. To use this feature, do the following: imgproxy can collect metrics for Prometheus. To use this feature, do the following:
1. Set `IMGPROXY_PROMETHEUS_BIND` environment variable. Note that you can't bind the main server and Prometheus to the same port; 1. Set the `IMGPROXY_PROMETHEUS_BIND` environment variable to the address and port that will be listened to by the Prometheus server. Note that you can't bind the main server and Prometheus to the same port.
2. _(optional)_ Set `IMGPROXY_PROMETHEUS_NAMESPACE` to prepend prefix to the names of metrics. 2. _(optional)_ Set the `IMGPROXY_PROMETHEUS_NAMESPACE` to prepend prefix to the names of metrics, i.e. with `IMGPROXY_PROMETHEUS_NAMESPACE=imgproxy` Names will appear like `imgproxy_requests_total`.
I.e. with `IMGPROXY_PROMETHEUS_NAMESPACE=imgproxy` names will look like `imgproxy_requests_total`.
3. Collect the metrics from any path on the specified binding. 3. Collect the metrics from any path on the specified binding.
imgproxy will collect the following metrics: imgproxy will collect the following metrics:
* `requests_total` - a counter of the total number of HTTP requests imgproxy processed; * `requests_total`: a counter with the total number of HTTP requests imgproxy has processed
* `errors_total` - a counter of the occurred errors separated by type (timeout, downloading, processing); * `errors_total`: a counter of the occurred errors separated by type (timeout, downloading, processing)
* `request_duration_seconds` - a histogram of the response latency (seconds); * `request_duration_seconds`: a histogram of the response latency (in seconds)
* `download_duration_seconds` - a histogram of the source image downloading latency (seconds); * `download_duration_seconds`: a histogram of the source image downloading latency (in seconds)
* `processing_duration_seconds` - a histogram of the image processing latency (seconds); * `processing_duration_seconds`: a histogram of the image processing latency (in seconds)
* `buffer_size_bytes` - a histogram of the download/gzip buffers sizes (bytes); * `buffer_size_bytes`: a histogram of the download/gzip buffers sizes (in bytes)
* `buffer_default_size_bytes` - calibrated default buffer size (bytes); * `buffer_default_size_bytes`: calibrated default buffer size (in bytes)
* `buffer_max_size_bytes` - calibrated maximum buffer size (bytes); * `buffer_max_size_bytes`: calibrated maximum buffer size (in bytes)
* `vips_memory_bytes` - libvips memory usage; * `vips_memory_bytes`: libvips memory usage
* `vips_max_memory_bytes` - libvips maximum memory usage; * `vips_max_memory_bytes`: libvips maximum memory usage
* `vips_allocs` - the number of active vips allocations; * `vips_allocs`: the number of active vips allocations
* Some useful Go metrics like memstats and goroutines count. * Some useful Go metrics like memstats and goroutines count

View File

@ -2,7 +2,7 @@
imgproxy can process images from Azure Blob Storage containers. To use this feature, do the following: imgproxy can process images from Azure Blob Storage containers. To use this feature, do the following:
1. Set `IMGPROXY_USE_ABS` environment variable as `true`; 1. Set `IMGPROXY_USE_ABS` environment variable to `true`
2. Set `IMGPROXY_ABS_NAME` to your Azure account name and `IMGPROXY_ABS_KEY` to your Azure account key; 2. Set `IMGPROXY_ABS_NAME` to your Azure account name and `IMGPROXY_ABS_KEY` to your Azure account key
4. _(optional)_ Specify Azure Blob Storage endpoint with `IMGPROXY_ABS_ENDPOINT`; 4. _(optional)_ Specify the Azure Blob Storage endpoint with `IMGPROXY_ABS_ENDPOINT`
4. Use `abs://%bucket_name/%file_key` as the source image URL. 4. Use `abs://%bucket_name/%file_key` as the source image URL

View File

@ -2,11 +2,11 @@
imgproxy can process images from Google Cloud Storage buckets. To use this feature, do the following: imgproxy can process images from Google Cloud Storage buckets. To use this feature, do the following:
1. Set `IMGPROXY_USE_GCS` environment variable as `true`; 1. Set the `IMGPROXY_USE_GCS` environment variable to `true`.
2. [Setup credentials](#setup-credentials) to grant access to your bucket; 2. [Set up credentials](#setup-credentials) to grant access to your bucket.
3. Use `gs://%bucket_name/%file_key` as the source image URL. 3. Use `gs://%bucket_name/%file_key` as the source image URL.
If you need to specify generation of the source object, you can use query string of the source URL: If you need to specify generation of the source object, you can use the query string of the source URL:
``` ```
gs://%bucket_name/%file_key?%generation gs://%bucket_name/%file_key?%generation
@ -14,6 +14,6 @@ gs://%bucket_name/%file_key?%generation
### Setup credentials ### Setup credentials
If you run imgproxy inside Google Cloud infrastructure (Compute Engine, Kubernetes Engine, App Engine, and Cloud Functions, etc), and you have granted access to your bucket to the service account, you probably don't need doing anything here. imgproxy will try to use the credentials provided by Google. If you run imgproxy inside Google Cloud infrastructure (Compute Engine, Kubernetes Engine, App Engine, and Cloud Functions, etc), and you have granted access to your bucket to the service account, you probably don't need to do anything here. imgproxy will try to use the credentials provided by Google.
Otherwise, set `IMGPROXY_GCS_KEY` environment variable to the content of Google Cloud JSON key. Get more info about JSON keys: [https://cloud.google.com/iam/docs/creating-managing-service-account-keys](https://cloud.google.com/iam/docs/creating-managing-service-account-keys). Otherwise, set `IMGPROXY_GCS_KEY` environment variable to the content of Google Cloud JSON key. Get more info about JSON keys: [https://cloud.google.com/iam/docs/creating-managing-service-account-keys](https://cloud.google.com/iam/docs/creating-managing-service-account-keys).

View File

@ -2,25 +2,25 @@
imgproxy can process images from S3 buckets. To use this feature, do the following: imgproxy can process images from S3 buckets. To use this feature, do the following:
1. Set `IMGPROXY_USE_S3` environment variable as `true`; 1. Set the `IMGPROXY_USE_S3` environment variable to be `true`.
2. [Setup credentials](#setup-credentials) to grant access to your bucket; 2. [Set up the necessary credentials](#setup-credentials) to grant access to your bucket.
3. _(optional)_ Specify AWS region with `IMGPROXY_S3_REGION` or `AWS_REGION`. Default: `us-west-1`; 3. _(optional)_ Specify the AWS region with `IMGPROXY_S3_REGION` or `AWS_REGION`. Default: `us-west-1`
4. _(optional)_ Specify S3 endpoint with `IMGPROXY_S3_ENDPOINT`; 4. _(optional)_ Specify the S3 endpoint with `IMGPROXY_S3_ENDPOINT`.
5. Use `s3://%bucket_name/%file_key` as the source image URL. 5. Use `s3://%bucket_name/%file_key` as the source image URL.
If you need to specify version of the source object, you can use query string of the source URL: If you need to specify the version of the source object, you can use the query string of the source URL:
``` ```
s3://%bucket_name/%file_key?%version_id s3://%bucket_name/%file_key?%version_id
``` ```
### Setup credentials ### Set up credentials
There are three ways to specify your AWS credentials. The credentials need to have read rights for all of the buckets given in the source URLs. There are three ways to specify your AWS credentials. The credentials need to have read rights for all of the buckets given in the source URLs.
#### Environment variables #### Environment variables
You can specify AWS Acces Key ID and Secret Access Key by setting the standard `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. You can specify an AWS Access Key ID and a Secret Access Key by setting the standard `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables.
``` bash ``` bash
AWS_ACCESS_KEY_ID=my_access_key AWS_SECRET_ACCESS_KEY=my_secret_key imgproxy AWS_ACCESS_KEY_ID=my_access_key AWS_SECRET_ACCESS_KEY=my_secret_key imgproxy
@ -29,11 +29,11 @@ AWS_ACCESS_KEY_ID=my_access_key AWS_SECRET_ACCESS_KEY=my_secret_key imgproxy
docker run -e AWS_ACCESS_KEY_ID=my_access_key -e AWS_SECRET_ACCESS_KEY=my_secret_key -it darthsim/imgproxy docker run -e AWS_ACCESS_KEY_ID=my_access_key -e AWS_SECRET_ACCESS_KEY=my_secret_key -it darthsim/imgproxy
``` ```
It is the recommended way to use with dockerized imgproxy. This is the recommended method when using dockerized imgproxy.
#### Shared credentials file #### Shared credentials file
Otherwise, you can create the `.aws/credentials` file in your home directory with the following content: Alternatively, you can create the `.aws/credentials` file in your home directory with the following content:
```ini ```ini
[default] [default]
@ -43,7 +43,7 @@ aws_secret_access_key = %secret_access_key
#### IAM Roles for Amazon EC2 Instances #### IAM Roles for Amazon EC2 Instances
If you are running imgproxy on an Amazon EC2 instance, you can use the instance's [IAM role](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html) to get security credentials to make calls to AWS S3. If you're running imgproxy on an Amazon EC2 instance, you can use the instance's [IAM role](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html) to get the security credentials to make calls to AWS S3.
You can learn about credentials in the [Configuring the AWS SDK for Go](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html) guide. You can learn about credentials in the [Configuring the AWS SDK for Go](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html) guide.
@ -53,5 +53,5 @@ You can learn about credentials in the [Configuring the AWS SDK for Go](https://
To use Minio as source images provider, do the following: To use Minio as source images provider, do the following:
* Setup Amazon S3 support as usual using environment variables or shared config file; * Set up Amazon S3 support as usual using environment variables or a shared config file.
* Specify endpoint with `IMGPROXY_S3_ENDPOINT`. Use `http://...` endpoint to disable SSL. * Specify an endpoint with `IMGPROXY_S3_ENDPOINT`. Use the `http://...` endpoint to disable SSL.

View File

@ -7,19 +7,19 @@ imgproxy can be configured to process files from your local filesystem. To use t
### Example ### Example
Assume you want to process an image that stored locally at `/path/to/project/images/logos/evil_martians.png`. Run imgproxy with `IMGPROXY_LOCAL_FILESYSTEM_ROOT` set to your images directory: Assume you want to process an image that is stored locally at `/path/to/project/images/logos/evil_martians.png`. Run imgproxy with `IMGPROXY_LOCAL_FILESYSTEM_ROOT` set to your images directory:
```bash ```bash
IMGPROXY_LOCAL_FILESYSTEM_ROOT=/path/to/project/images imgproxy IMGPROXY_LOCAL_FILESYSTEM_ROOT=/path/to/project/images imgproxy
``` ```
Then use path inside this directory as the source URL: Then, use the path inside this directory as the source URL:
``` ```
local:///logos/evil_martians.png local:///logos/evil_martians.png
``` ```
The URl for resizing this image to fit 300x200 will look like this: The URL for resizing this image to fit 300x200 will look like this:
``` ```
http://imgproxy.example.com/insecure/rs:fit:300:200:no:0/plain/local:///logos/evil_martians.png@jpg http://imgproxy.example.com/insecure/rs:fit:300:200:no:0/plain/local:///logos/evil_martians.png@jpg

View File

@ -1,17 +1,17 @@
# Signing the URL # Signing the URL
imgproxy allows you to sign your URLs with key and salt, so an attacker won't be able to cause a denial-of-service attack by requesting multiple different image resizes. imgproxy allows you to sign your URLs with a key and salt, so an attacker won’t be able to perform a denial-of-service attack by requesting multiple different image resizes.
### Configuring URL signature ### Configuring URL signature
URL signature checking is disabled by default, but it is highly recommended to enable it in a production environment. To do so, the define key/salt pair by setting the following environment variables: URL signature checking is disabled by default, but it is highly recommended to enable it in a production environment. To do so, define a key/salt pair by setting the following environment variables:
* `IMGPROXY_KEY`: hex-encoded key; * `IMGPROXY_KEY`: hex-encoded key
* `IMGPROXY_SALT`: hex-encoded salt; * `IMGPROXY_SALT`: hex-encoded salt
Read our [Configuration](configuration.md#url-signature) guide to find more ways to set key and salt. Read our [Configuration](configuration.md#url-signature) guide to learn more ways of setting keys and salts.
If you need a random key/salt pair real fast, you can quickly generate it using, for example, the following snippet: If you need a random key/salt pair in a hurry, you can quickly generate one using the following snippet:
```bash ```bash
echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n') echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
@ -19,20 +19,21 @@ echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
### Calculating URL signature ### Calculating URL signature
Signature is an URL-safe Base64-encoded HMAC digest of the rest of the path, including the leading `/`. Here is how it is calculated: A signature is a URL-safe Base64-encoded HMAC digest of the rest of the path, including the leading `/`. Here’s how it’s calculated:
* Take the path part after the signature:
* For [processing URLs](generating_the_url.md): `/%processing_options/%encoded_url.%extension` or `/%processing_options/plain/%plain_url@%extension`; * Take the part of the path after the signature:
* For [info URLs](getting_the_image_info.md): `/%encoded_url` or `/plain/%plain_url`; * For [processing URLs](generating_the_url.md): `/%processing_options/%encoded_url.%extension` or `/%processing_options/plain/%plain_url@%extension`
* Add salt to the beginning; * For [info URLs](getting_the_image_info.md): `/%encoded_url` or `/plain/%plain_url`
* Calculate the HMAC digest using SHA256; * Add a salt to the beginning.
* Calculate the HMAC digest using SHA256.
* Encode the result with URL-safe Base64. * Encode the result with URL-safe Base64.
### Example ### Example
**You can find helpful code snippets in various programming languages the [examples](https://github.com/imgproxy/imgproxy/tree/master/examples) folder. There is a good chance you will find a snippet in your favorite programming language that you can use right away.** **You can find helpful code snippets in various programming languages the [examples](https://github.com/imgproxy/imgproxy/tree/master/examples) folder. There's a good chance you'll find a snippet in your favorite programming language that you'll be able to use right away.**
And here is a step-by-step example of calculating the URL signature: And here is a step-by-step example of URL signature creation:
Assume that you have the following unsigned URL: Assume that you have the following unsigned URL:
@ -40,13 +41,13 @@ Assume that you have the following unsigned URL:
http://imgproxy.example.com/insecure/rs:fill:300:400:0/g:sm/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png http://imgproxy.example.com/insecure/rs:fill:300:400:0/g:sm/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
``` ```
To sign it, you need to configure imgproxy to use your key/salt pair. Let's say, your key and salt are `secret` and `hello` — that translates to `736563726574` and `68656C6C6F` in hex encoding. This key/salt pair is quite weak for production use but will do for this example. Run your imgproxy using this key/salt pair: To sign it, you need to configure imgproxy to use your key/salt pair. Let's say, your key and salt are `secret` and `hello`, respectively — that translates to `736563726574` and `68656C6C6F` in hex encoding. This key/salt pair is quite weak for production purposes but will do for this example. Run imgproxy using this key/salt pair, like so:
```bash ```bash
IMGPROXY_KEY=736563726574 IMGPROXY_SALT=68656C6C6F imgproxy IMGPROXY_KEY=736563726574 IMGPROXY_SALT=68656C6C6F imgproxy
``` ```
Note that all your unsigned URL will stop working since imgproxy now checks signatures of all URLs. Note that all your unsigned URL will stop working since imgproxy now checks all URL signatures.
First, you need to take the path after the signature and add the salt to the beginning: First, you need to take the path after the signature and add the salt to the beginning:
@ -60,10 +61,10 @@ Then calculate the HMAC digest of this string using SHA256 and encode it with UR
oKfUtW34Dvo2BGQehJFR4Nr0_rIjOtdtzJ3QFsUcXH8 oKfUtW34Dvo2BGQehJFR4Nr0_rIjOtdtzJ3QFsUcXH8
``` ```
And finally put the signature to your URL: And finally, add the signature to your URL:
``` ```
http://imgproxy.example.com/oKfUtW34Dvo2BGQehJFR4Nr0_rIjOtdtzJ3QFsUcXH8/rs:fill:300:400:0/g:sm/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png http://imgproxy.example.com/oKfUtW34Dvo2BGQehJFR4Nr0_rIjOtdtzJ3QFsUcXH8/rs:fill:300:400:0/g:sm/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
``` ```
Now you got the URL that you can use to resize the image securely. Now you have a URL that you can use to securely resize the image.

View File

@ -1,58 +1,58 @@
# Watermark # Watermark
imgproxy supports watermarking processed images with another image. imgproxy supports the watermarking of processed images using another image.
## Specifying watermark image ## Specifying watermark image
There are three ways to specify a watermark image using environment variables: There are three ways to specify a watermark image using environment variables:
* `IMGPROXY_WATERMARK_PATH`: path to the locally stored image. * `IMGPROXY_WATERMARK_PATH`: the path to the locally stored image
* `IMGPROXY_WATERMARK_URL`: watermark image URL. * `IMGPROXY_WATERMARK_URL`: the watermark image URL
* `IMGPROXY_WATERMARK_DATA`: Base64-encoded image data. You can easily calculate it with the following snippet: * `IMGPROXY_WATERMARK_DATA`: Base64-encoded image data. You can easily calculate it with the following snippet:
```bash ```bash
base64 tmp/watermark.webp | tr -d '\n'`. base64 tmp/watermark.webp | tr -d '\n'`.
``` ```
You can also specify the base opacity of watermark with `IMGPROXY_WATERMARK_OPACITY`. You can also specify the base opacity of a watermark using `IMGPROXY_WATERMARK_OPACITY`.
**📝Note:** If you're going to use `scale` argument of `watermark`, it's highly recommended to use SVG, WebP or JPEG watermarks since these formats support scale-on-load. **📝Note:** If you're going to use the `scale` argument of `watermark`, it's highly recommended to use SVG, WebP or JPEG watermarks since these formats support scale-on-load.
## Watermarking an image ## Watermarking an image
Use `watermark` processing option to put the watermark on the processed image: Use the `watermark` processing option to put a watermark on a processed image:
``` ```
watermark:%opacity:%position:%x_offset:%y_offset:%scale watermark:%opacity:%position:%x_offset:%y_offset:%scale
wm:%opacity:%position:%x_offset:%y_offset:%scale wm:%opacity:%position:%x_offset:%y_offset:%scale
``` ```
Where arguments are: The available arguments are:
* `opacity` - watermark opacity modifier. Final opacity is calculated like `base_opacity * opacity`. * `opacity` - watermark opacity modifier. The final opacity is calculated as `base_opacity * opacity`.
* `position` - (optional) specifies the position of the watermark. Available values: * `position` - (optional) specifies the position of the watermark. Available values:
* `ce`: (default) center; * `ce`: (default) center
* `no`: north (top edge); * `no`: north (top edge)
* `so`: south (bottom edge); * `so`: south (bottom edge)
* `ea`: east (right edge); * `ea`: east (right edge)
* `we`: west (left edge); * `we`: west (left edge)
* `noea`: north-east (top-right corner); * `noea`: north-east (top-right corner)
* `nowe`: north-west (top-left corner); * `nowe`: north-west (top-left corner)
* `soea`: south-east (bottom-right corner); * `soea`: south-east (bottom-right corner)
* `sowe`: south-west (bottom-left corner); * `sowe`: south-west (bottom-left corner)
* `re`: replicate watermark to fill the whole image; * `re`: repeat and tile the watermark to fill the entire image
* `x_offset`, `y_offset` - (optional) specify watermark offset by X and Y axes. Not applicable to `re` position; * `x_offset`, `y_offset` - (optional) specify watermark offset by X and Y axes. When using `re` position, these values define the spacing between the tiles.
* `scale` - (optional) floating point number that defines watermark size relative to the resulting image size. When set to `0` or omitted, watermark size won't be changed. * `scale` - (optional) a floating point number that defines the watermark size relative to the resulting image size. When set to `0` or omitted, the watermark size won't be changed.
## Custom watermarks<i class='badge badge-pro'></i> :id=custom-watermarks ## Custom watermarks<i class='badge badge-pro'></i> :id=custom-watermarks
You can use a custom watermark specifying its URL with `watermark_url` processing option: You can use a custom watermark by specifying its URL with the `watermark_url` processing option:
``` ```
watermark_url:%url watermark_url:%url
wmu:%url wmu:%url
``` ```
Where `url` is Base64-encoded URL of the custom watermark. The value of `url` should be the Base64-encoded URL of the custom watermark.
By default imgproxy caches 256 custom watermarks with adaptive replacement cache (ARC). You can change the cache size with `IMGPROXY_WATERMARKS_CACHE_SIZE` environment variable. When `IMGPROXY_WATERMARKS_CACHE_SIZE` is set to `0`, the cache is disabled. By default, imgproxy caches 256 custom watermarks with an adaptive replacement cache (ARC). You can change the cache size using the `IMGPROXY_WATERMARKS_CACHE_SIZE` environment variable. When `IMGPROXY_WATERMARKS_CACHE_SIZE` is set to `0`, the cache is disabled.