1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-01-08 10:45:04 +02:00
imgproxy/docs/generating_the_url.md

916 lines
31 KiB
Markdown
Raw Normal View History

2021-03-15 13:26:38 +02:00
# Generating the URL
2018-10-04 14:59:57 +02:00
2021-03-15 13:26:38 +02:00
The URL should contain the signature, processing options, and source URL, like this:
2018-10-04 14:59:57 +02:00
```
2018-11-02 17:35:21 +02:00
/%signature/%processing_options/plain/%source_url@%extension
/%signature/%processing_options/%encoded_source_url.%extension
2018-10-04 14:59:57 +02:00
```
Check out the [example](#example) at the end of this guide.
2021-03-15 13:26:38 +02:00
## Signature
2018-10-04 14:59:57 +02:00
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.
2018-10-04 14:59:57 +02:00
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.
2018-10-04 14:59:57 +02:00
2021-03-15 13:26:38 +02:00
## Processing options
2018-10-04 14:59:57 +02:00
Processing options should be specified as URL parts divided by slashes (`/`). A processing option has the following format:
2018-10-04 14:59:57 +02:00
```
%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 maximum performance. Read more about this in the [About processing pipeline](about_processing_pipeline.md) guide.
2018-10-04 14:59:57 +02:00
imgproxy supports the following processing options:
2021-03-15 13:26:38 +02:00
### Resize
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
2019-02-21 17:55:20 +02:00
resize:%resizing_type:%width:%height:%enlarge:%extend
rs:%resizing_type:%width:%height:%enlarge:%extend
2018-10-25 21:56:08 +02:00
```
2018-10-04 14:59:57 +02:00
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.
2018-10-04 14:59:57 +02:00
2021-03-15 13:26:38 +02:00
### Size
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
2019-02-21 17:55:20 +02:00
size:%width:%height:%enlarge:%extend
s:%width:%height:%enlarge:%extend
2018-10-25 21:56:08 +02:00
```
2018-10-04 14:59:57 +02:00
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.
2018-10-04 14:59:57 +02:00
2021-03-15 13:26:38 +02:00
### Resizing type
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
resizing_type:%resizing_type
rt:%resizing_type
```
2018-10-04 14:59:57 +02:00
Defines how imgproxy will resize the source image. Supported resizing types are:
* `fit`: resizes the image while keeping aspect ratio to fit a given size.
* `fill`: resizes the image while keeping aspect ratio to fill a given size and crops projecting parts.
2022-02-21 10:39:09 +02:00
* `fill-down`: 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 the aspect ratio.
2019-06-24 14:50:17 +02:00
* `auto`: if both source and resulting dimensions have the same orientation (portrait or landscape), imgproxy will use `fill`. Otherwise, it will use `fit`.
2018-10-04 14:59:57 +02:00
Default: `fit`
2022-12-15 17:06:52 +02:00
### Resizing algorithm![pro](./assets/pro.svg) :id=resizing-algorithm
2019-12-09 14:56:19 +02:00
```
resizing_algorithm:%algorithm
ra:%algorithm
```
Defines the algorithm that imgproxy will use for resizing. Supported algorithms are `nearest`, `linear`, `cubic`, `lanczos2`, and `lanczos3`.
Default: `lanczos3`
2021-03-15 13:26:38 +02:00
### Width
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
width:%width
w:%width
```
2018-10-04 14:59:57 +02:00
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 resizing type is `force`, imgproxy will keep the original width.
2018-10-04 14:59:57 +02:00
Default: `0`
2021-03-15 13:26:38 +02:00
### Height
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
height:%height
h:%height
```
2018-10-04 14:59:57 +02:00
Defines the height of the resulting image. When set to `0`, imgproxy will calculate resulting height using the defined width and source aspect ratio. When set to `0` and resizing type is `force`, imgproxy will keep the original height.
2018-10-04 14:59:57 +02:00
Default: `0`
2022-02-21 10:39:09 +02:00
### Min width
```
min-width:%width
mw:%width
```
Defines the minimum width of the resulting image.
2023-02-23 20:23:16 +02:00
**⚠️ Warning:** When both `width` and `min-width` are set, the final image will be cropped according to `width`, so use this combination with care.
Default: `0`
2022-02-21 10:39:09 +02:00
### Min height
```
min-height:%height
mh:%height
```
Defines the minimum height of the resulting image.
2023-02-23 20:23:16 +02:00
**⚠️ Warning:** When both `height` and `min-height` are set, the final image will be cropped according to `height`, so use this combination with care.
Default: `0`
2022-01-18 12:09:32 +02:00
### Zoom
```
zoom:%zoom_x_y
z:%zoom_x_y
2022-12-15 16:46:07 +02:00
zoom:%zoom_x:%zoom_y
z:%zoom_x:%zoom_y
2022-01-18 12:09:32 +02:00
```
When set, imgproxy will multiply the image dimensions according to these factors. The values must be greater than 0.
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.
2023-02-23 20:23:16 +02:00
**📝 Note:** Unlike [dpr](#dpr), `zoom` doesn't set the `Content-DPR` header in the response.
2022-01-18 12:09:32 +02:00
Default: `1`
2021-03-15 13:26:38 +02:00
### Dpr
2018-11-15 14:58:35 +02:00
```
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.
2023-02-23 20:23:16 +02:00
**📝 Note:** `dpr` also sets the `Content-DPR` header in the response so the browser can correctly render the image.
2022-01-18 12:09:32 +02:00
2018-11-15 14:58:35 +02:00
Default: `1`
2021-03-15 13:26:38 +02:00
### Enlarge
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
enlarge:%enlarge
el:%enlarge
```
2018-10-04 14:59:57 +02:00
When set to `1`, `t` or `true`, imgproxy will enlarge the image if it is smaller than the given size.
2018-10-04 14:59:57 +02:00
Default: `false`
2018-10-04 14:59:57 +02:00
2021-03-15 13:26:38 +02:00
### Extend
2019-02-21 17:55:20 +02:00
```
2019-12-25 12:50:02 +02:00
extend:%extend:%gravity
ex:%extend:%gravity
2019-02-21 17:55:20 +02:00
```
2019-12-25 12:50:02 +02:00
* 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 the [gravity](#gravity) option, except `sm`. When `gravity` is not set, imgproxy will use `ce` gravity without offsets.
Default: `false:ce:0:0`
### Extend aspect ratio
```
extend_aspect_ratio:%extend:%gravity
extend_ar:%extend:%gravity
exar:%extend:%gravity
```
* When `extend` is set to `1`, `t` or `true`, imgproxy will extend the image to the requested aspect ratio.
* `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.
2019-02-21 17:55:20 +02:00
2019-12-25 12:50:02 +02:00
Default: `false:ce:0:0`
2019-02-21 17:55:20 +02:00
2021-03-15 13:26:38 +02:00
### Gravity
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
2021-01-20 11:54:47 +02:00
gravity:%type:%x_offset:%y_offset
g:%type:%x_offset:%y_offset
2018-10-25 21:56:08 +02:00
```
2018-10-04 14:59:57 +02:00
When imgproxy needs to cut some parts of the image, it is guided by the gravity option.
2018-10-04 14:59:57 +02:00
2021-01-20 11:54:47 +02:00
* `type` - specifies the gravity type. Available values:
* `no`: north (top edge)
* `so`: south (bottom edge)
* `ea`: east (right edge)
* `we`: west (left edge)
* `noea`: north-east (top-right corner)
* `nowe`: north-west (top-left corner)
* `soea`: south-east (bottom-right corner)
* `sowe`: south-west (bottom-left corner)
* `ce`: center
* `x_offset`, `y_offset` - (optional) specifies the gravity offset along the X and Y axes.
2018-10-04 14:59:57 +02:00
2019-06-20 14:49:25 +02:00
Default: `ce:0:0`
**Special gravities**:
2019-06-20 14:49:25 +02:00
* `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.
2022-12-15 17:06:52 +02:00
* `gravity:obj:%class_name1:%class_name2:...:%class_nameN`: ![pro](./assets/pro.svg) 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`: 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`.
2018-10-04 14:59:57 +02:00
2021-03-15 13:26:38 +02:00
### Crop
2019-06-13 10:20:11 +02:00
```
crop:%width:%height:%gravity
c:%width:%height:%gravity
```
Defines an area of the image to be processed (crop before resize).
2021-01-18 17:14:15 +02:00
* `width` and `height` define the size of the area:
* 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 set to `0`, imgproxy will use the full width/height of the source image.
* `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.
2019-06-13 10:20:11 +02:00
2021-03-15 13:26:38 +02:00
### Trim
2020-01-17 11:54:50 +02:00
```
2020-04-07 14:34:49 +02:00
trim:%threshold:%color:%equal_hor:%equal_ver
t:%threshold:%color:%equal_hor:%equal_ver
2020-01-17 11:54:50 +02:00
```
Removes surrounding background.
2020-04-07 14:34:49 +02:00
* `threshold` - color similarity tolerance.
* `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 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.
2020-04-07 14:34:49 +02:00
* `equal_ver` - _(optional)_ acts like `equal_hor` but for top/bottom sides.
2020-01-17 11:54:50 +02:00
2023-02-23 20:23:16 +02:00
**⚠️ 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.
2023-02-23 20:23:16 +02:00
**📝 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.
2023-02-23 20:23:16 +02:00
**📝 Note:** Use a `color` value of `FF00FF` for trimming transparent backgrounds as imgproxy uses magenta as a transparency key.
2023-02-23 20:23:16 +02:00
**📝 Note:** The trimming of animated images is not supported.
2020-01-17 11:54:50 +02:00
### Padding
2021-01-13 16:51:19 +02:00
```
padding:%top:%right:%bottom:%left
pd:%top:%right:%bottom:%left
2021-01-13 16:51:19 +02:00
```
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.
2021-01-13 16:51:19 +02:00
* `top` - top padding (and for all other sides if they haven't been explicitly st)
* `right` - right padding (and left if it hasn't been explicitly set)
* `bottom` - bottom padding
* `left` - left padding
2021-01-13 16:51:19 +02:00
2023-02-23 20:23:16 +02:00
**📝 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.
2021-01-13 16:51:19 +02:00
2023-02-23 20:23:16 +02:00
**📝 Note:** Padding follows the [dpr](#dpr) option so it will also be scaled if you've set it.
2023-01-31 16:01:11 +02:00
### Auto rotate
2018-10-30 14:20:02 +02:00
```
auto_rotate:%auto_rotate
ar:%auto_rotate
2018-10-30 14:20:02 +02:00
```
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.
2018-10-30 14:20:02 +02:00
### Rotate
```
rotate:%angle
rot:%angle
```
Rotates the image on the specified angle. The orientation from the image metadata is applied before the rotation unless autorotation is disabled.
2023-02-23 20:23:16 +02:00
**📝 Note:** Only 0, 90, 180, 270, etc., degree angles are supported.
Default: 0
2021-03-15 13:26:38 +02:00
### Background
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
background:%R:%G:%B
bg:%R:%G:%B
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
background:%hex_color
bg:%hex_color
```
2018-10-04 14:59:57 +02:00
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.
2018-10-04 14:59:57 +02:00
2018-10-08 08:23:20 +02:00
With no arguments provided, disables any background manipulations.
2018-10-04 14:59:57 +02:00
Default: disabled
2022-12-15 17:06:52 +02:00
### Background alpha![pro](./assets/pro.svg) :id=background-alpha
2020-08-10 13:38:37 +02:00
```
background_alpha:%alpha
bga:%alpha
```
Adds an alpha channel to `background`. The value of `alpha` is a positive floating point number between `0` and `1`.
2020-08-10 13:38:37 +02:00
Default: 1
2022-12-15 17:06:52 +02:00
### Adjust![pro](./assets/pro.svg) :id=adjust
2019-10-14 12:02:23 +02:00
```
adjust:%brightness:%contrast:%saturation
a:%brightness:%contrast:%saturation
```
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.
2019-10-14 12:02:23 +02:00
2022-12-15 17:06:52 +02:00
### Brightness![pro](./assets/pro.svg) :id=brightness
2019-10-14 12:02:23 +02:00
```
brightness:%brightness
br:%brightness
```
When set, imgproxy will adjust brightness of the resulting image. `brightness` is an integer number ranging from `-255` to `255`.
2019-10-14 12:02:23 +02:00
Default: 0
2022-12-15 17:06:52 +02:00
### Contrast![pro](./assets/pro.svg) :id=contrast
2019-10-14 12:02:23 +02:00
```
contrast:%contrast
co:%contrast
```
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.
2019-10-14 12:02:23 +02:00
Default: 1
2022-12-15 17:06:52 +02:00
### Saturation![pro](./assets/pro.svg) :id=saturation
2019-10-14 12:02:23 +02:00
```
saturation:%saturation
2019-10-14 12:55:58 +02:00
sa:%saturation
2019-10-14 12:02:23 +02:00
```
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.
2019-10-14 12:02:23 +02:00
Default: 1
2021-03-15 13:26:38 +02:00
### Blur
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
blur:%sigma
bl:%sigma
```
2018-10-04 14:59:57 +02:00
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.
2018-10-04 14:59:57 +02:00
Default: disabled
2021-03-15 13:26:38 +02:00
### Sharpen
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
sharpen:%sigma
sh:%sigma
```
2018-10-04 14:59:57 +02:00
2022-04-05 14:16:20 +02:00
When set, imgproxy will apply the sharpen filter to the resulting image. The value of `sigma` defines the size of the mask imgproxy will use.
2018-10-04 14:59:57 +02:00
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).
Default: disabled
2021-04-27 12:23:22 +02:00
### Pixelate
2019-10-11 15:20:28 +02:00
```
pixelate:%size
pix:%size
```
When set, imgproxy will apply the pixelate filter to the resulting image. The value of `size` defines individual pixel size.
2019-10-11 15:20:28 +02:00
Default: disabled
2022-12-15 17:06:52 +02:00
### Unsharpening![pro](./assets/pro.svg) :id=unsharpening
```
unsharpening:%mode:%weight:%dividor
ush:%mode:%weight:%dividor
```
Allows redefining unsharpening options. All arguments have the same meaning as [Unsharpening](configuration.md#unsharpening) configs. All arguments are optional and can be omitted.
2022-12-15 17:06:52 +02:00
### Blur detections![pro](./assets/pro.svg) :id=blur-detections
2021-09-28 18:57:46 +02:00
```
blur_detections:%sigma:%class_name1:%class_name2:...:%class_nameN
bd:%sigma:%class_name1:%class_name2:...:%class_nameN
```
imgproxy [detects objects](object_detection.md) of the provided classes and blurs them. If class names are omitted, imgproxy blurs all the detected objects.
2021-09-28 18:57:46 +02:00
The value of `sigma` defines the size of the mask imgproxy will use.
2021-09-28 18:57:46 +02:00
2022-12-15 17:06:52 +02:00
### Draw detections![pro](./assets/pro.svg) :id=draw-detections
2021-09-28 18:57:46 +02:00
```
draw_detections:%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 the provided classes and draws their bounding boxes. If class names are omitted, imgproxy draws the bounding boxes of all the detected objects.
2021-09-28 18:57:46 +02:00
2022-12-15 17:06:52 +02:00
### Gradient![pro](./assets/pro.svg) :id=gradient
2022-10-24 13:48:32 +02:00
```
gradient:%opacity:%color:%direction:%start%stop
gr:%opacity:%color:%direction:%start%stop
```
Places a gradient on the processed image. The placed gradient transitions from transparency to the specified color.
* `opacity`: specifies gradient opacity. When set to `0`, gradient is not applied.
* `color`: _(optional)_ a hex-coded value of the gradient color. Default: `000` (black).
* `direction`: _(optional)_ specifies the direction of the gradient. Available values:
* `down`: _(default)_ the top side of the gradient is transparrent, the bottom side is opaque
* `up`: the bottom side of the gradient is transparrent, the top side is opaque
* `right`: the left side of the gradient is transparrent, the right side is opaque
* `left`: the right side of the gradient is transparrent, the left side is opaque
* `start`, `stop`: floating point numbers that define relative positions of where the gradient starts and where it ends. Default values are `0.0` and `1.0` respectively.
2021-03-15 13:26:38 +02:00
### Watermark
2018-10-25 21:56:08 +02:00
```
2018-10-28 14:05:57 +02:00
watermark:%opacity:%position:%x_offset:%y_offset:%scale
wm:%opacity:%position:%x_offset:%y_offset:%scale
2018-10-25 21:56:08 +02:00
```
Places a watermark on the processed image.
* `opacity`: watermark opacity modifier. Final opacity is calculated like `base_opacity * opacity`.
* `position`: (optional) specifies the position of the watermark. Available values:
* `ce`: (default) center
* `no`: north (top edge)
* `so`: south (bottom edge)
* `ea`: east (right edge)
* `we`: west (left edge)
* `noea`: north-east (top-right corner)
* `nowe`: north-west (top-left corner)
* `soea`: south-east (bottom-right corner)
* `sowe`: south-west (bottom-left corner)
2022-02-07 14:11:30 +02:00
* `re`: repeat and tile the watermark to fill the entire image
* `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) 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
2022-12-15 17:06:52 +02:00
### Watermark URL![pro](./assets/pro.svg) :id=watermark-url
2019-10-11 15:20:28 +02:00
```
watermark_url:%url
wmu:%url
```
2023-01-31 16:01:11 +02:00
When set, imgproxy will use the image from the specified URL as a watermark. `url` is the URL-safe Base64-encoded URL of the custom watermark.
2019-10-11 15:20:28 +02:00
Default: blank
2022-12-15 17:06:52 +02:00
### Watermark text![pro](./assets/pro.svg) :id=watermark-text
2021-12-07 14:52:00 +02:00
```
watermark_text:%text
wmt:%text
```
2023-01-31 16:01:11 +02:00
When set, imgproxy will generate an image from the provided text and use it as a watermark. `text` is the URL-safe Base64-encoded text of the custom watermark.
2021-12-07 14:52:00 +02:00
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.
2021-12-07 14:52:00 +02:00
If you want to use a custom font, you need to put it in `/usr/share/fonts` inside a container.
2021-12-07 14:52:00 +02:00
Default: blank
2023-01-31 16:01:11 +02:00
### Watermark size![pro](./assets/pro.svg) :id=watermark-size
2022-04-06 09:02:53 +02:00
```
watermark_size:%width:%height
wms:%width:%height
```
Defines the desired width and height of the watermark. imgproxy always uses `fit` resizing type when resizing watermarks and enlarges them when needed.
When `%width` is set to `0`, imgproxy will calculate the width using the defined height and watermark's aspect ratio.
When `%height` is set to `0`, imgproxy will calculate the height using the defined width and watermark's aspect ratio.
2023-02-23 20:23:16 +02:00
**📝 Note:** This processing option takes effect only when the `scale` argument of the `watermark` option is set to zero.
2022-04-06 09:02:53 +02:00
Default: `0:0`
2023-01-31 16:01:11 +02:00
### Watermark shadow![pro](./assets/pro.svg) :id=watermark-shadow
2022-10-07 13:34:48 +02:00
```
watermark_shadow:%sigma
wmsh:%sigma
```
When set, imgproxy will add a shadow to the watermark. The value of `sigma` defines the size of the mask imgproxy will use to blur the shadow.
Default: disabled
2022-12-15 17:06:52 +02:00
### Style![pro](./assets/pro.svg) :id=style
2019-10-11 15:20:28 +02:00
```
style:%style
st:%style
```
2023-01-31 16:01:11 +02:00
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.
2019-10-11 15:20:28 +02:00
Default: blank
2023-01-31 16:01:11 +02:00
### Strip metadata
```
strip_metadata:%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. 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.
2023-01-31 16:01:11 +02:00
### Keep copyright
```
keep_copyright:%keep_copyright
kcr:%keep_copyright
```
When set to `1`, `t` or `true`, imgproxy will not remove copyright info while stripping metadata. This is normally controlled by the [IMGPROXY_KEEP_COPYRIGHT](configuration.md#miscellaneous) configuration but this procesing option allows the configuration to be set for each request.
2023-01-31 16:01:11 +02:00
### Strip color profile
```
strip_color_profile:%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. 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.
### Enforce thumbnail
```
enforce_thumbnail:%enforce_thumbnail
eth:%enforce_thumbnail
```
2022-04-18 11:03:03 +02:00
When set to `1`, `t` or `true` and the source image has an embedded thumbnail, imgproxy will always use the embedded thumbnail instead of the main image. Currently, only thumbnails embedded in `heic` and `avif` are supported. This is normally controlled by the [IMGPROXY_ENFORCE_THUMBNAIL](configuration.md#miscellaneous) configuration but this procesing option allows the configuration to be set for each request.
### Quality
```
quality:%quality
q:%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.
2022-02-21 10:39:09 +02:00
### Format quality
2021-09-29 15:49:18 +02:00
```
format_quality:%format1:%quality1:%format2:%quality2:...:%formatN:%qualityN
fq:%format1:%quality1:%format2:%quality2:...:%formatN:%qualityN
```
Adds or redefines `IMGPROXY_FORMAT_QUALITY` values.
2022-12-15 17:06:52 +02:00
### Autoquality![pro](./assets/pro.svg) :id=autoquality
2021-09-28 18:57:46 +02:00
```
autoquality:%method:%target:%min_quality:%max_quality:%allowed_error
aq:%method:%target:%min_quality:%max_quality:%allowed_error
```
2022-01-27 20:35:11 +02:00
Redefines autoquality settings. All arguments have the same meaning as [Autoquality](configuration.md#autoquality) configs. All arguments are optional and can be omitted.
2021-09-28 18:57:46 +02:00
2023-02-23 20:23:16 +02:00
**⚠️ Warning:** Autoquality requires the image to be saved several times. Use it only when you prefer the resulting size and quality over the speed.
2021-09-28 18:57:46 +02:00
2023-01-31 16:01:11 +02:00
### Max bytes
```
max_bytes:%bytes
mb:%bytes
```
When set, imgproxy automatically degrades the quality of the image until the image size is under the specified amount of bytes.
2023-02-23 20:23:16 +02:00
**📝 Note:** Applicable only to `jpg`, `webp`, `heic`, and `tiff`.
2023-02-23 20:23:16 +02:00
**⚠️ Warning:** When `max_bytes` is set, imgproxy saves image multiple times to achieve the specified image size.
Default: 0
2022-12-15 17:06:52 +02:00
### JPEG options![pro](./assets/pro.svg) :id=jpeg-options
2019-12-09 11:44:23 +02:00
```
jpeg_options:%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 the [Advanced JPEG compression](configuration.md#advanced-jpeg-compression) configs. All arguments are optional and can be omitted.
2019-12-09 11:44:23 +02:00
2022-12-15 17:06:52 +02:00
### PNG options![pro](./assets/pro.svg) :id=png-options
2019-12-09 11:44:23 +02:00
```
2021-02-01 15:18:35 +02:00
png_options:%interlaced:%quantize:%quantization_colors
pngo:%interlaced:%quantize:%quantization_colors
2019-12-09 11:44:23 +02:00
```
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.
2019-12-09 11:44:23 +02:00
2022-12-15 17:06:52 +02:00
<!-- ### GIF options![pro](./assets/pro.svg) :id=gif-options
```
2021-02-01 15:18:35 +02:00
gif_options:%optimize_frames:%optimize_transparency
gifo:%optimize_frames:%optimize_transparency
```
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. -->
2022-12-15 17:06:52 +02:00
### WebP options![pro](./assets/pro.svg) :id=webp-options
2022-12-05 16:43:25 +02:00
```
webp_options:%compression
webpo:%compression
```
Allows redefining WebP saving options. All arguments have the same meaning as with the [Advanced WebP compression](configuration.md#advanced-webp-compression) configs. All arguments are optional and can be omitted.
### Format
```
format:%extension
f:%extension
ext:%extension
```
Specifies the resulting image format. Alias for the [extension](#extension) part of the URL.
Default: `jpg`
2022-12-15 17:06:52 +02:00
### Page![pro](./assets/pro.svg) :id=page
```
page:%page
pg:%page
```
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
2022-12-15 17:06:52 +02:00
### Disable animation![pro](./assets/pro.svg) :id=disable-animation
2022-10-24 13:48:32 +02:00
```
disable_animation:%disable
da:%disable
```
When set to `1`, `t` or `true`, imgproxy will use a single frame of animated images. Use the [page](#page) option to specify which frame imgproxy should use.
Default: `false`
2022-12-15 17:06:52 +02:00
### Video thumbnail second![pro](./assets/pro.svg) :id=video-thumbnail-second
2020-08-07 14:35:36 +02:00
```
video_thumbnail_second:%second
vts:%second
```
Allows redefining `IMGPROXY_VIDEO_THUMBNAIL_SECOND` config.
2022-12-15 17:06:52 +02:00
### Fallback image URL![pro](./assets/pro.svg) :id=fallback-image-url
2021-04-16 18:42:08 +02:00
You can use a custom fallback image by specifying its URL with the `fallback_image_url` processing option:
2021-04-16 18:42:08 +02:00
```
fallback_image_url:%url
fiu:%url
```
2023-01-31 16:01:11 +02:00
The value of `url` is the URL-safe Base64-encoded URL of the custom fallback image.
2021-04-16 18:42:08 +02:00
Default: blank
2022-02-21 10:39:09 +02:00
### Skip processing
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
skip_processing:%extension1:%extension2:...:%extensionN
skp:%extension1:%extension2:...:%extensionN
2018-10-25 21:56:08 +02:00
```
2018-10-04 14:59:57 +02:00
When set, imgproxy will skip the processing of the listed formats. Also available as the [IMGPROXY_SKIP_PROCESSING_FORMATS](configuration.md#skip-processing) configuration.
2018-10-04 14:59:57 +02:00
2023-02-23 20:23:16 +02:00
**📝 Note:** Processing can only be skipped when the requested format is the same as the source format.
2023-02-23 20:23:16 +02:00
**📝 Note:** Video thumbnail processing can't be skipped.
2018-10-04 14:59:57 +02:00
Default: empty
2022-09-07 12:50:21 +02:00
### Raw
```
raw:%raw
```
When set to `1`, `t` or `true`, imgproxy will respond with a raw unprocessed, and unchecked source image. There are some differences between `raw` and `skip_processing` options:
* While the `skip_processing` option has some conditions to skip the processing, the `raw` option allows to skip processing no matter what
* With the `raw` option set, imgproxy doesn't check the source image's type, resolution, and file size. Basically, the `raw` option allows streaming of any file type
* With the `raw` option set, imgproxy won't download the whole image to the memory. Instead, it will stream the source image directly to the response lowering memory usage
* The requests with the `raw` option set are not limited by the `IMGPROXY_CONCURRENCY` config
Default: `false`
2021-03-15 13:26:38 +02:00
### Cache buster
2018-10-29 10:54:30 +02:00
```
cachebuster:%string
cb:%string
```
Cache buster doesn't affect image processing but its 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.
2018-10-29 10:54:30 +02:00
It's highly recommended to prefer the `cachebuster` option over a URL query string because that option can be properly signed.
2018-10-29 10:54:30 +02:00
Default: empty
2022-02-21 10:39:09 +02:00
### Expires
```
expires:%timestamp
exp:%timestamp
```
When set, imgproxy will check the provided unix timestamp and return 404 when expired.
Default: empty
2021-03-15 13:26:38 +02:00
### Filename
2019-08-13 16:57:43 +02:00
```
2019-08-21 14:24:36 +02:00
filename:%string
2019-08-13 16:57:43 +02:00
fn:%string
```
Defines a filename for the `Content-Disposition` header. When not specified, imgproxy will get the filename from the source url.
2019-08-13 16:57:43 +02:00
Default: empty
2022-09-05 12:55:38 +02:00
### Return attachment
```
return_attachment:%return_attachment
att:%return_attachment
```
When set to `1`, `t` or `true`, imgproxy will return `attachment` in the `Content-Disposition` header, and the browser will open a 'Save as' dialog. This is normally controlled by the [IMGPROXY_RETURN_ATTACHMENT](configuration.md#miscellaneous) configuration but this procesing option allows the configuration to be set for each request.
### Preset
2018-10-04 14:59:57 +02:00
2018-10-25 21:56:08 +02:00
```
preset:%preset_name1:%preset_name2:...:%preset_nameN
pr:%preset_name1:%preset_name2:...:%preset_nameN
2018-10-25 21:56:08 +02:00
```
2018-10-04 14:59:57 +02:00
Defines a list of presets to be used by imgproxy. Feel free to use as many presets in a single URL as you need.
2018-10-04 14:59:57 +02:00
Read more about presets in the [Presets](presets.md) guide.
Default: empty
2018-10-04 14:59:57 +02:00
2023-02-23 20:11:44 +02:00
### Max src resolution
```
max_src_resolution:%resolution
msr:%resolution
```
Allows redefining `IMGPROXY_MAX_SRC_RESOLUTION` config.
2023-02-23 20:23:16 +02:00
**⚠️ Warning:** Since this option allows redefining a security restriction, its usage is not allowed unless the `IMGPROXY_ALLOW_SECURITY_OPTIONS` config is set to `true`.
2023-02-23 20:11:44 +02:00
### Max src file size
```
max_src_file_size:%size
msfs:%size
```
Allows redefining `IMGPROXY_MAX_SRC_FILE_SIZE` config.
2023-02-23 20:23:16 +02:00
**⚠️ Warning:** Since this option allows redefining a security restriction, its usage is not allowed unless the `IMGPROXY_ALLOW_SECURITY_OPTIONS` config is set to `true`.
2023-02-23 20:11:44 +02:00
### Max animation frames
```
max_animation_frames:%size
maf:%size
```
Allows redefining `IMGPROXY_MAX_ANIMATION_FRAMES` config.
2023-02-23 20:23:16 +02:00
**⚠️ Warning:** Since this option allows redefining a security restriction, its usage is not allowed unless the `IMGPROXY_ALLOW_SECURITY_OPTIONS` config is set to `true`.
2023-02-23 20:11:44 +02:00
### Max animation frame resolution
```
max_animation_frame_resolution:%size
mafr:%size
```
Allows redefining `IMGPROXY_MAX_ANIMATION_FRAME_RESOLUTION` config.
2023-02-23 20:23:16 +02:00
**⚠️ Warning:** Since this option allows redefining a security restriction, its usage is not allowed unless the `IMGPROXY_ALLOW_SECURITY_OPTIONS` config is set to `true`.
2023-02-23 20:11:44 +02:00
2021-03-15 13:26:38 +02:00
## Source URL
### Plain
2018-11-02 17:35:21 +02:00
The source URL can be provided as is, prepended by the `/plain/` segment:
2018-11-02 17:35:21 +02:00
2018-11-02 18:33:56 +02:00
```
/plain/http://example.com/images/curiosity.jpg
```
2023-02-23 20:23:16 +02:00
**📝 Note:** If the source URL contains a query string or `@`, you'll need to escape it.
2018-11-02 18:33:56 +02:00
When using a plain source URL, you can specify the [extension](#extension) after `@`:
2018-11-02 18:33:56 +02:00
```
/plain/http://example.com/images/curiosity.jpg@png
```
2018-11-02 17:35:21 +02:00
2021-03-15 13:26:38 +02:00
### Base64 encoded
2018-11-02 17:35:21 +02:00
The source URL can be encoded with URL-safe Base64. The encoded URL can be split with `/` as desired:
2018-11-02 17:35:21 +02:00
2018-11-02 18:33:56 +02:00
```
/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn
```
When using an encoded source URL, you can specify the [extension](#extension) after `.`:
2018-11-02 18:33:56 +02:00
```
/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
```
2018-10-04 14:59:57 +02:00
2022-11-07 17:14:39 +02:00
### Encrypted with AES-CBC
The source URL can be encrypted with the AES-CBC algorithm, prepended by the `/enc/` segment. The encrypted URL can be split with `/` as desired:
```
/enc/jwV3wUD9r4VBIzgv/ang3Hbh0vPpcm5cc/VO5rHxzonpvZjppG/2VhDnX2aariBYegH/jlhw_-dqjXDMm4af/ZDU6y5sBog
```
When using an encrypted source URL, you can specify the [extension](#extension) after `.`:
```
/enc/jwV3wUD9r4VBIzgv/ang3Hbh0vPpcm5cc/VO5rHxzonpvZjppG/2VhDnX2aariBYegH/jlhw_-dqjXDMm4af/ZDU6y5sBog.png
```
2021-03-15 13:26:38 +02:00
## Extension
2018-10-04 14:59:57 +02:00
Extension specifies the format of the resulting image. Read more about image formats support [here](image_formats_support.md).
2018-10-04 14:59:57 +02:00
2022-12-05 16:43:25 +02:00
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#avifwebp-support-detection) to use it as the default resulting format when possible.
2022-12-15 17:06:52 +02:00
### Best format![pro](./assets/pro.svg)
2022-12-05 16:43:25 +02:00
You can use the `best` value for the [format](generating_the_url#format) option or the [extension](generating_the_url#extension) to make imgproxy pick the best format for the resultant image. Check out the [Best format](best_format) guide to learn more.
2018-10-04 14:59:57 +02:00
2019-09-18 14:04:01 +02:00
## Example
2018-10-04 14:59:57 +02:00
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`:
2018-10-04 14:59:57 +02:00
```
2018-11-02 17:35:21 +02:00
http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/preset:sharp/resize:fill:300:400:0/gravity:sm/plain/http://example.com/images/curiosity.jpg@png
2018-10-04 14:59:57 +02:00
```
The same URL with shortcuts will look like this:
2018-11-02 17:35:21 +02:00
```
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 a Base64-encoded source URL will look like this:
2018-11-02 17:35:21 +02:00
2018-10-04 14:59:57 +02:00
```
http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/pr:sharp/rs:fill:300:400:0/g:sm/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
```