1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-02-07 11:36:25 +02:00

Remove basic URL format

This commit is contained in:
DarthSim 2021-03-15 17:26:38 +06:00
parent baf00f64f2
commit ceb9a61976
21 changed files with 131 additions and 303 deletions

View File

@ -16,11 +16,11 @@
### Added
- AVIF support.
- Azure Blob Storage support.
- `IMGPROXY_STRIP_COLOR_PROFILE` config and [strip_color_profile](https://docs.imgproxy.net/#/generating_the_url_advanced?id=strip-color-profile) processing option.
- `IMGPROXY_STRIP_COLOR_PROFILE` config and [strip_color_profile](https://docs.imgproxy.net/#/generating_the_url?id=strip-color-profile) processing option.
- `IMGPROXY_FORMAT_QUALITY` config.
- `IMGPROXY_AUTO_ROTATE` config and [auto_rotate](https://docs.imgproxy.net/#/generating_the_url_advanced?id=auto-rotate) processing option.
- [rotate](https://docs.imgproxy.net/#/generating_the_url_advanced?id=rotate) processing option.
- `width` and `height` arguments of the [crop](https://docs.imgproxy.net/#/generating_the_url_advanced?id=crop) processing option can be less than `1` that is treated by imgproxy as a relative value (a.k.a. crop by percentage).
- `IMGPROXY_AUTO_ROTATE` config and [auto_rotate](https://docs.imgproxy.net/#/generating_the_url?id=auto-rotate) processing option.
- [rotate](https://docs.imgproxy.net/#/generating_the_url?id=rotate) processing option.
- `width` and `height` arguments of the [crop](https://docs.imgproxy.net/#/generating_the_url?id=crop) processing option can be less than `1` that is treated by imgproxy as a relative value (a.k.a. crop by percentage).
- (pro) Remove Adobe Illustrator garbage from SVGs.
- (pro) Add IPTC tags to the `/info` response.
@ -41,9 +41,9 @@
### Added
- Ability to skip processing of some formats. See [Skip processing](https://docs.imgproxy.net/#/configuration?id=skip-processing).
- (pro) PDF support.
- (pro) [video_thumbnail_second](https://docs.imgproxy.net/#/generating_the_url_advanced?id=video-thumbnail-second) processing option.
- (pro) [page](https://docs.imgproxy.net/#/generating_the_url_advanced?id=page) processing option.
- (pro) [background_alpha](https://docs.imgproxy.net/#/generating_the_url_advanced?id=background-alpha) processing option.
- (pro) [video_thumbnail_second](https://docs.imgproxy.net/#/generating_the_url?id=video-thumbnail-second) processing option.
- (pro) [page](https://docs.imgproxy.net/#/generating_the_url?id=page) processing option.
- (pro) [background_alpha](https://docs.imgproxy.net/#/generating_the_url?id=background-alpha) processing option.
- (pro) `IMGPROXY_VIDEO_THUMBNAIL_PROBE_SIZE` and `IMGPROXY_VIDEO_THUMBNAIL_MAX_ANALYZE_DURATION` configs.
### Changed
@ -61,8 +61,8 @@
## [2.14.0] - 2020-07-17
### Added
- `IMGPROXY_PROMETHEUS_NAMESPACE` config.
- [strip_metadata](https://docs.imgproxy.net/#/generating_the_url_advanced?id=strip-metadata) processing option.
- (pro) Configurable unsharpening. See [Unsharpening](https://docs.imgproxy.net/#/configuration?id=unsharpening) configs and [unsharpening](https://docs.imgproxy.net/#/generating_the_url_advanced?id=unsharpening) processing option.
- [strip_metadata](https://docs.imgproxy.net/#/generating_the_url?id=strip-metadata) processing option.
- (pro) Configurable unsharpening. See [Unsharpening](https://docs.imgproxy.net/#/configuration?id=unsharpening) configs and [unsharpening](https://docs.imgproxy.net/#/generating_the_url?id=unsharpening) processing option.
### Changed
- Better for libvips memory metrics for Prometheus.
@ -84,7 +84,7 @@
## [2.13.0] - 2020-04-22
### Added
- Fallback images.
- [padding](https://docs.imgproxy.net/#/generating_the_url_advanced?id=padding) processing option.
- [padding](https://docs.imgproxy.net/#/generating_the_url?id=padding) processing option.
### Changed
- Optimized memory usage. Especially when dealing with animated images.
@ -211,7 +211,7 @@
## [2.4.0] - 2019-08-20
### Added
- `SO_REUSEPORT` socker option support. Can be enabled with `IMGPROXY_SO_REUSEPORT`.
- [filename](./docs/generating_the_url_advanced.md#filename) option.
- [filename](./docs/generating_the_url.md#filename) option.
### Changed
- Better handling if non-sRGB images.
@ -228,8 +228,8 @@
- `libvips` v8.8 support: better processing of animated GIFs, built-in CMYK profile, better WebP scale-on-load, etc;
- Animated WebP support. `IMGPROXY_MAX_GIF_FRAMES` is deprecated, use `IMGPROXY_MAX_ANIMATION_FRAMES`;
- [HEIC support](./docs/image_formats_support.md#heic-support);
- [crop](./docs/generating_the_url_advanced.md#crop) processing option. `resizing_type:crop` is deprecated;
- Offsets for [gravity](./docs/generating_the_url_advanced.md#gravity);
- [crop](./docs/generating_the_url.md#crop) processing option. `resizing_type:crop` is deprecated;
- Offsets for [gravity](./docs/generating_the_url.md#gravity);
- Resizing type `auto`. If both source and resulting dimensions have the same orientation (portrait or landscape), imgproxy will use `fill`. Otherwise, it will use `fit`;
- Development errors mode. When `IMGPROXY_DEVELOPMENT_ERRORS_MODE` is true, imgproxy will respond with detailed error messages. Not recommended for production because some errors may contain stack trace;
- `IMGPROXY_KEEP_ALIVE_TIMEOUT` config.
@ -287,7 +287,7 @@ Fixed processing of images with embedded profiles that was broken in v2.2.8.
## [2.2.5] - 2019-02-21
### Added
- [extend](./docs/generating_the_url_advanced.md#extend) processing option.
- [extend](./docs/generating_the_url.md#extend) processing option.
- `vips_memory_bytes`, `vips_max_memory_bytes` and `vips_allocs` metrics for Prometheus.
### Fixed
@ -357,15 +357,15 @@ Fixed processing of images with embedded profiles that was broken in v2.2.8.
## [2.1.0] - 2018-11-16
### Added
- [Plain source URLs](./docs/generating_the_url_advanced.md#plain) support.
- [Plain source URLs](./docs/generating_the_url.md#plain) support.
- [Serving images from Google Cloud Storage](./docs/serving_files_from_google_cloud_storage.md).
- [Full support of GIFs](./docs/image_formats_support.md#gif-support) including animated ones.
- [Watermarks](./docs/watermark.md).
- [New Relic](./docs/new_relic.md) metrics.
- [Prometheus](./docs/prometheus.md) metrics.
- [DPR](./docs/generating_the_url_advanced.md#dpr) option (thanks to [selul](https://github.com/selul)).
- [Cache buster](./docs/generating_the_url_advanced.md#cache-buster) option.
- [Quality](./docs/generating_the_url_advanced.md#quality) option.
- [DPR](./docs/generating_the_url.md#dpr) option (thanks to [selul](https://github.com/selul)).
- [Cache buster](./docs/generating_the_url.md#cache-buster) option.
- [Quality](./docs/generating_the_url.md#quality) option.
- Support for custom [Amazon S3](./docs/serving_files_from_s3.md) endpoints.
- Support for [Amazon S3](./docs/serving_files_from_s3.md) versioning.
- [Client hints](./docs/configuration.md#client-hints-support) support (thanks to [selul](https://github.com/selul)).
@ -394,13 +394,13 @@ Fixed processing of images with embedded profiles that was broken in v2.2.8.
## [2.0.0] - 2018-10-08
All-You-Ever-Wanted release! :tada:
### Added
- [New advanced URL format](./docs/generating_the_url_advanced.md). Unleash the full power of imgproxy v2.0.
- [New advanced URL format](./docs/generating_the_url.md). Unleash the full power of imgproxy v2.0.
- [Presets](./docs/presets.md). Shorten your urls by reusing processing options.
- [Serving images from Amazon S3](./docs/serving_files_from_s3.md). Thanks to [@crohr](https://github.com/crohr), now we have a way to serve files from private S3 buckets.
- [Autoconverting to WebP when supported by browser](./docs/configuration.md#webp-support-detection) (disabled by default). Use WebP as resulting format when browser supports it.
- [Gaussian blur](./docs/generating_the_url_advanced.md#blur) and [sharpen](./docs/generating_the_url_advanced.md#sharpen) filters. Make your images look better than before.
- [Focus point gravity](./docs/generating_the_url_advanced.md#gravity). Tell imgproxy what point will be the center of the image.
- [Background color](./docs/generating_the_url_advanced.md#background). Control the color of background when converting PNG with alpha-channel to JPEG.
- [Gaussian blur](./docs/generating_the_url.md#blur) and [sharpen](./docs/generating_the_url.md#sharpen) filters. Make your images look better than before.
- [Focus point gravity](./docs/generating_the_url.md#gravity). Tell imgproxy what point will be the center of the image.
- [Background color](./docs/generating_the_url.md#background). Control the color of background when converting PNG with alpha-channel to JPEG.
### Changed
- Key and salt are not required anymore. When key or salt is not specified, signature checking is disabled.

View File

@ -1,8 +1,7 @@
* [Getting started](GETTING_STARTED)
* [Installation](installation)
* [Configuration](configuration)
* [Generating the URL (Basic)](generating_the_url_basic)
* [Generating the URL (Advanced)](generating_the_url_advanced)
* [Generating the URL](generating_the_url)
* [Getting the image info <img class='pro-badge' src='assets/pro.svg' alt='pro' />](getting_the_image_info)
* [Signing the URL](signing_the_url)
* [Watermark](watermark)

View File

@ -1,10 +1,6 @@
# Generating the URL (Advanced)
# Generating the URL
This guide describes the advanced URL format that allows the use of all the imgproxy features. Read our [Generating the URL (Basic)](generating_the_url_basic.md) guide to learn about the _basic_ URL format that is compatible with imgproxy 1.x.
## Format definition
The advanced URL should contain the signature, processing options, and source URL, like this:
The URL should contain the signature, processing options, and source URL, like this:
```
/%signature/%processing_options/plain/%source_url@%extension
@ -13,13 +9,13 @@ The advanced URL should contain the signature, processing options, and source UR
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.
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.
### Processing options
## Processing options
Processing options should be specified as URL parts divided by slashes (`/`). Processing option has the following format:
@ -31,7 +27,7 @@ The list of processing options does not define imgproxy's processing pipeline. I
imgproxy supports the following processing options:
#### Resize
### Resize
```
resize:%resizing_type:%width:%height:%enlarge:%extend
@ -40,7 +36,7 @@ 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.
#### Size
### Size
```
size:%width:%height:%enlarge:%extend
@ -49,7 +45,7 @@ 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.
#### Resizing type
### Resizing type
```
resizing_type:%resizing_type
@ -64,7 +60,7 @@ Defines how imgproxy will resize the source image. Supported resizing types are:
Default: `fit`
#### Resizing algorithm<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Resizing algorithm<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
resizing_algorithm:%algorithm
@ -75,7 +71,7 @@ Defines the algorithm that imgproxy will use for resizing. Supported algorithms
Default: `lanczos3`
#### Width
### Width
```
width:%width
@ -86,7 +82,7 @@ Defines the width of the resulting image. When set to `0`, imgproxy will calcula
Default: `0`
#### Height
### Height
```
height:%height
@ -97,7 +93,7 @@ Defines the height of the resulting image. When set to `0`, imgproxy will calcul
Default: `0`
#### Dpr
### Dpr
```
dpr:%dpr
@ -107,7 +103,7 @@ When set, imgproxy will multiply the image dimensions according to this factor f
Default: `1`
#### Enlarge
### Enlarge
```
enlarge:%enlarge
@ -118,7 +114,7 @@ When set to `1`, `t` or `true`, imgproxy will enlarge the image if it is smaller
Default: false
#### Extend
### Extend
```
extend:%extend:%gravity
@ -130,7 +126,7 @@ ex:%extend:%gravity
Default: `false:ce:0:0`
#### Gravity
### Gravity
```
gravity:%type:%x_offset:%y_offset
@ -158,7 +154,7 @@ Default: `ce:0:0`
* `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: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`.
#### Crop
### Crop
```
crop:%width:%height:%gravity
@ -173,7 +169,7 @@ Defines an area of the image to be processed (crop before resize).
* 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.
#### Padding
### Padding
```
padding:%top:%right:%bottom:%left
@ -191,7 +187,7 @@ Defines padding size in css manner. All arguments are optional but at least one
**📝Note:** Padding follows [dpr](#dpr) option so it will be scaled too if you set it.
#### Trim
### Trim
```
trim:%threshold:%color:%equal_hor:%equal_ver
@ -211,7 +207,7 @@ Removes surrounding background.
**📝Note:** Trimming of animated images is not supported.
#### Rotate
### Rotate
```
rotate:%angle
@ -224,7 +220,7 @@ Rotates the image on the specified angle. The orientation from the image metadat
Default: 0.
#### Quality
### Quality
```
quality:%quality
@ -235,7 +231,7 @@ Redefines quality of the resulting image, percentage. When `0`, quality is assum
Default: 0.
#### Max Bytes
### Max Bytes
```
max_bytes:%bytes
@ -250,7 +246,7 @@ When set, imgproxy automatically degrades the quality of the image until the ima
Default: 0
#### Background
### Background
```
background:%R:%G:%B
@ -266,7 +262,7 @@ With no arguments provided, disables any background manipulations.
Default: disabled
#### Background alpha<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Background alpha<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
background_alpha:%alpha
@ -277,7 +273,7 @@ Adds alpha channel to `background`. `alpha` is a positive floating point number
Default: 1
#### Adjust<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Adjust<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
adjust:%brightness:%contrast:%saturation
@ -286,7 +282,7 @@ 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.
#### Brightness<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Brightness<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
brightness:%brightness
@ -297,7 +293,7 @@ When set, imgproxy will adjust brightness of the resulting image. `brightness` i
Default: 0
#### Contrast<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Contrast<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
contrast:%contrast
@ -308,7 +304,7 @@ When set, imgproxy will adjust contrast of the resulting image. `contrast` is a
Default: 1
#### Saturation<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Saturation<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
saturation:%saturation
@ -319,7 +315,7 @@ When set, imgproxy will adjust saturation of the resulting image. `saturation` i
Default: 1
#### Blur
### Blur
```
blur:%sigma
@ -330,7 +326,7 @@ When set, imgproxy will apply the gaussian blur filter to the resulting image. `
Default: disabled
#### Sharpen
### Sharpen
```
sharpen:%sigma
@ -343,7 +339,7 @@ As an approximate guideline, use 0.5 sigma for 4 pixels/mm (display resolution),
Default: disabled
#### Pixelate<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Pixelate<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
pixelate:%size
@ -354,7 +350,7 @@ When set, imgproxy will apply the pixelate filter to the resulting image. `size`
Default: disabled
#### Unsharpening<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Unsharpening<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
unsharpening:%mode:%weight:%dividor
@ -363,7 +359,7 @@ 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.
#### Watermark
### Watermark
```
watermark:%opacity:%position:%x_offset:%y_offset:%scale
@ -389,7 +385,7 @@ Puts watermark on the processed image.
Default: disabled
#### Watermark URL<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Watermark URL<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
watermark_url:%url
@ -400,7 +396,7 @@ When set, imgproxy will use the image from the specified URL as a watermark. `ur
Default: blank
#### Style<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Style<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
style:%style
@ -411,7 +407,7 @@ When set, imgproxy will prepend `<style>` node with provided content to the `<sv
Default: blank
#### JPEG options<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### JPEG options<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
jpeg_options:%progressive:%no_subsample:%trellis_quant:%overshoot_deringing:%optimize_scans:%quant_table
@ -420,7 +416,7 @@ jpgo:%progressive:%no_subsample:%trellis_quant:%overshoot_deringing:%optimize_sc
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.
#### PNG options<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### PNG options<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
png_options:%interlaced:%quantize:%quantization_colors
@ -429,7 +425,7 @@ 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.
#### GIF options<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### GIF options<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
gif_options:%optimize_frames:%optimize_transparency
@ -438,7 +434,7 @@ 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.
#### Page<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Page<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
page:%page
@ -449,7 +445,7 @@ When source image supports pagination (PDF, TIFF) or animation (GIF, WebP), this
Default: 0
#### Video thumbnail second<img class='pro-badge' src='assets/pro.svg' alt='pro' />
### Video thumbnail second<img class='pro-badge' src='assets/pro.svg' alt='pro' />
```
video_thumbnail_second:%second
@ -458,7 +454,7 @@ vts:%second
Allows redefining `IMGPROXY_VIDEO_THUMBNAIL_SECOND` config.
#### Preset
### Preset
```
preset:%preset_name1:%preset_name2:...:%preset_nameN
@ -471,7 +467,7 @@ Read more about presets in the [Presets](presets.md) guide.
Default: empty
#### Cache buster
### Cache buster
```
cachebuster:%string
@ -484,7 +480,7 @@ It's highly recommended to prefer `cachebuster` option over URL query string bec
Default: empty
#### Strip Metadata
### Strip Metadata
```
strip_metadata:%strip_metadata
@ -493,7 +489,7 @@ 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.
#### Strip Color Profile
### Strip Color Profile
```
strip_color_profile:%strip_color_profile
@ -502,7 +498,7 @@ 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.
#### Auto Rotate
### Auto Rotate
```
auto_rotate:%auto_rotate
@ -511,7 +507,7 @@ 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.
#### Filename
### Filename
```
filename:%string
@ -522,7 +518,7 @@ Defines a filename for `Content-Disposition` header. When not specified, imgprox
Default: empty
#### Format
### Format
```
format:%extension
@ -534,11 +530,11 @@ Specifies the resulting image format. Alias for [extension](#extension) URL part
Default: `jpg`
### Source URL
## Source URL
There are two ways to specify source url:
#### Plain
### Plain
The source URL can be provided as is, prendended by `/plain/` part:
@ -554,7 +550,7 @@ When using plain source URL, you can specify the [extension](#extension) after `
/plain/http://example.com/images/curiosity.jpg@png
```
#### Base64 encoded
### Base64 encoded
The source URL can be encoded with URL-safe Base64. The encoded URL can be split with `/` for your needs:
@ -568,7 +564,7 @@ When using encoded source URL, you can specify the [extension](#extension) after
/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
```
### Extension
## Extension
Extension specifies the format of the resulting image. Read about image formats support [here](image_formats_support.md).

View File

@ -1,106 +0,0 @@
# Generating the URL (Basic)
This guide describes the simple URL format that is easy to use but doesn't support the whole range of imgproxy features. This URL format is mostly supported for backwards compatibility with imgproxy 1.x. Please read our [Generating the URL (Advanced)](generating_the_url_advanced.md) guide to learn about the advanced URL format.
## Format definition
The basic URL should contain the signature, resize parameters, and source URL, like this:
```
/%signature/%resizing_type/%width/%height/%gravity/%enlarge/plain/%source_url@%extension
/%signature/%resizing_type/%width/%height/%gravity/%enlarge/%encoded_source_url.%extension
```
Check out the [example](#example) at the end of this guide.
### Signature
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.
### Resizing types
imgproxy supports the following resizing types:
* `fit`: resizes the image while keeping aspect ratio to fit given size;
* `fill`: resizes the image while keeping aspect ratio to fill given size and cropping projecting parts;
* `auto`: if both source and resulting dimensions have the same orientation (portrait or landscape), imgproxy will use `fill`. Otherwise, it will use `fit`.
### Width and height
Width and height parameters define the size of the resulting image in pixels. Depending on the resizing type applied, the dimensions may differ from the requested ones.
### Gravity
When imgproxy needs to cut some parts of the image, it is guided by the gravity. The following values are supported:
* `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;
* `sm`: smart. `libvips` detects the most "interesting" section of the image and considers it as the center of the resulting image;
* `fp:%x:%y` - focus point. `x` and `y` are floating point numbers between 0 and 1 that describe the coordinates of the center of the resulting image. Treat 0 and 1 as right/left for `x` and top/bottom for `y`.
### Enlarge
When set to `1`, `t` or `true`, imgproxy will enlarge the image if it is smaller than the given size.
### Source URL
There are two ways to specify source url:
#### Plain
The source URL can be provided as is, prepended by `/plain/` part:
```
/plain/http://example.com/images/curiosity.jpg
```
**📝Note:** If the sorce URL contains query string or `@`, you need to escape it.
When using plain source URL, you can specify the [extension](#extension) after `@`:
```
/plain/http://example.com/images/curiosity.jpg@png
```
#### Base64 encoded
The source URL can be encoded with URL-safe Base64. The encoded URL can be split with `/` for your needs:
```
/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn
```
When using encoded source URL, you can specify the [extension](#extension) after `.`:
```
/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
```
### Extension
Extension specifies the format of the resulting image. Read 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.
## Example
Signed imgproxy URL that resizes `http://example.com/images/curiosity.jpg` to fill `300x400` area with smart gravity without enlarging, and converts the image to `png`:
```
http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/fill/300/400/sm/0/plain/http://example.com/images/curiosity.jpg@png
```
The same URL with Base64-encoded source URL will look like this:
```
http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/fill/300/400/sm/0/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
```

View File

@ -1,6 +1,6 @@
# Presets
imgproxy preset is a named set of processing options. Presets can be used in [advanced URL format](generating_the_url_advanced.md#preset) to get shorter and somewhat readable URLs.
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.
## Presets definition
@ -10,7 +10,7 @@ The preset definition looks like this:
%preset_name=%processing_options
```
Processing options should be defined in the same way as you define them in the [advanced URL format](generating_the_url_advanced.md#preset). 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 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`:
```
awesome=resizing_type:fill/format:jpg

View File

@ -22,9 +22,8 @@ echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
Signature is an URL-safe Base64-encoded HMAC digest of the rest of the path, including the leading `/`. Here is how it is calculated:
* Take the path part after the signature:
* For [basic URL format](generating_the_url_basic.md): `/%resizing_type/%width/%height/%gravity/%enlarge/%encoded_url.%extension` or `/%resizing_type/%width/%height/%gravity/%enlarge/plain/%plain_url@%extension`;
* For [advanced URL format](generating_the_url_advanced.md): `/%processing_options/%encoded_url.%extension` or `/%processing_options/plain/%plain_url@%extension`;
* For [info URL](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`;
* For [info URLs](getting_the_image_info.md): `/%encoded_url` or `/plain/%plain_url`;
* Add salt to the beginning;
* Calculate the HMAC digest using SHA256;
* Encode the result with URL-safe Base64.
@ -38,7 +37,7 @@ And here is a step-by-step example of calculating the URL signature:
Assume that you have the following unsigned URL:
```
http://imgproxy.example.com/insecure/fill/300/400/sm/0/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:
@ -52,19 +51,19 @@ Note that all your unsigned URL will stop working since imgproxy now checks sign
First, you need to take the path after the signature and add the salt to the beginning:
```
hello/fill/300/400/sm/0/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
hello/rs:fill:300:400:0/g:sm/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
```
Then calculate the HMAC digest of this string using SHA256 and encode it with URL-safe Base64:
```
AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM
LzIKNN09Lv_LAJhmgqbC6_VFlm0qlW2El5riObZq3BQ
```
And finally put the signature to your URL:
```
http://imgproxy.example.com/AfrOrF3gWeDA6VOlDG4TzxMv39O7MXnF4CXpKUwGqRM/fill/300/400/sm/0/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/cy9jdXJpb3NpdHku/anBn.png
http://imgproxy.example.com/LzIKNN09Lv_LAJhmgqbC6_VFlm0qlW2El5riObZq3BQ/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.

View File

@ -19,7 +19,7 @@ You can also specify the base opacity of watermark with `IMGPROXY_WATERMARK_OPAC
## Watermarking an image
Watermarks are only available with [advanced URL format](generating_the_url_advanced.md). Use `watermark` processing option to put the watermark on the processed image:
Use `watermark` processing option to put the watermark on the processed image:
```
watermark:%opacity:%position:%x_offset:%y_offset:%scale

View File

@ -25,7 +25,7 @@ $extension = 'png';
$url = 'http://img.example.com/pretty/image.jpg';
$encodedUrl = rtrim(strtr(base64_encode($url), '+/', '-_'), '=');
$path = "/{$resize}/{$width}/{$height}/{$gravity}/{$enlarge}/{$encodedUrl}.{$extension}";
$path = "/rs:{$resize}:{$width}:{$height}:{$enlarge}/g:{$gravity}/{$encodedUrl}.{$extension}";
$signature = hash_hmac('sha256', $saltBin.$path, $keyBin, true);
$signature = pack('A'.IMGPROXY_SIGNATURE_SIZE, $signature);
$signature = rtrim(strtr(base64_encode($signature), '+/', '-_'), '=');

View File

@ -35,7 +35,7 @@ namespace ImgProxy.Examples
var saltBin = HexadecimalStringToByteArray(salt);
var encodedUrl = EncodeBase64URLSafeString(url);
var path = $"/{resize}/{width}/{height}/{gravity}/{enlarge}/{encodedUrl}.{extension}";
var path = $"/rs:{resize}:{width}:{height}:{enlarge}/g:{gravity}/{encodedUrl}.{extension}";
var passwordWithSaltBytes = new List<byte>();
passwordWithSaltBytes.AddRange(saltBin);

View File

@ -3,30 +3,30 @@ import 'package:convert/convert.dart';
import 'package:crypto/crypto.dart';
void main() {
var key = hex.decode("943b421c9eb07c830af81030552c86009268de4e532ba2ee2eab8247c6da0881");
var salt = hex.decode("520f986b998545b4785e0defbc4f3c1203f22de2374a3d53cb7a7fe9fea309c5");
var url = "http://img.example.com/pretty/image.jpg";
var key = hex.decode("943b421c9eb07c830af81030552c86009268de4e532ba2ee2eab8247c6da0881");
var salt = hex.decode("520f986b998545b4785e0defbc4f3c1203f22de2374a3d53cb7a7fe9fea309c5");
var url = "http://img.example.com/pretty/image.jpg";
var resizing_type = 'fill';
var width = 300;
var height = 300;
var gravity = 'no';
var enlarge = 1;
var extension = 'png';
var url_encoded = urlSafeBase64(utf8.encode(url));
var path = "/$resizing_type/$width/$height/$gravity/$enlarge/$url_encoded.$extension";
var url_encoded = urlSafeBase64(utf8.encode(url));
var path = "/rs:$resizing_type:$width:$height:$enlarge/g:$gravity/$url_encoded.$extension";
var signature = sign(salt, utf8.encode(path), key);
print("/$signature/$path");
print("/$signature/$path");
}
String urlSafeBase64(buffer) {
return base64.encode(buffer).replaceAll("=", "").replaceAll("+", "-").replaceAll("/", "_");
return base64.encode(buffer).replaceAll("=", "").replaceAll("+", "-").replaceAll("/", "_");
}
String sign(salt, path, key) {
var hmac = Hmac(sha256, key);
var digest = hmac.convert(salt + path);
return urlSafeBase64(digest.bytes);
}
var hmac = Hmac(sha256, key);
var digest = hmac.convert(salt + path);
return urlSafeBase64(digest.bytes);
}

View File

@ -13,11 +13,8 @@ defmodule App.Imgproxy do
defp build_path(img_url, opts) do
Path.join([
"/",
opts.resize,
to_string(opts.width),
to_string(opts.height),
opts.gravity,
to_string(opts.enlarge),
"rs:#{opts.resize}:#{opts.width}:#{opts.height}:#{opts.enlarge}",
"g:#{opts.gravity}",
Base.url_encode64(img_url, padding: false) <> "." <> opts.extension
])
end

View File

@ -34,7 +34,7 @@ func main() {
url := "http://img.example.com/pretty/image.jpg"
encodedURL := base64.RawURLEncoding.EncodeToString([]byte(url))
path := fmt.Sprintf("/%s/%d/%d/%s/%d/%s.%s", resize, width, height, gravity, enlarge, encodedURL, extension)
path := fmt.Sprintf("/rs:%s:%d:%d:%d/g:%s/%s.%s", resize, width, height, enlarge, gravity, encodedURL, extension)
mac := hmac.New(sha256.New, keyBin)
mac.Write(saltBin)

View File

@ -10,7 +10,7 @@ import javax.crypto.spec.SecretKeySpec;
import static org.junit.jupiter.api.Assertions.*;
public class ImgProxy{
@Test
public void testWithJavaHmacApacheBase64ImgProxyTest() throws Exception {
byte[] key = hexStringToByteArray("943b421c9eb07c830af81030552c86009268de4e532ba2ee2eab8247c6da0881");
@ -33,7 +33,7 @@ public class ImgProxy{
String encodedUrl = Base64.getUrlEncoder().withoutPadding().encodeToString(url.getBytes());
String path = "/" + resize + "/" + width + "/" + height + "/" + gravity + "/" + enlarge + "/" + encodedUrl + "." + extension;
String path = "/rs:" + resize + ":" + width + ":" + height + ":" + enlarge + "/g:" + gravity + "/" + encodedUrl + "." + extension;
Mac sha256HMAC = Mac.getInstance(HMACSHA256);
SecretKeySpec secretKey = new SecretKeySpec(key, HMACSHA256);

View File

@ -24,7 +24,7 @@ const gravity = 'no'
const enlarge = 1
const extension = 'png'
const encoded_url = urlSafeBase64(url)
const path = `/${resizing_type}/${width}/${height}/${gravity}/${enlarge}/${encoded_url}.${extension}`
const path = `/rs:${resizing_type}:${width}:${height}:${enlarge}/g:${gravity}/${encoded_url}.${extension}`
const signature = sign(SALT, path, KEY)
const result = `/${signature}${path}`

View File

@ -23,7 +23,7 @@ $extension = 'png';
$url = 'http://img.example.com/pretty/image.jpg';
$encodedUrl = rtrim(strtr(base64_encode($url), '+/', '-_'), '=');
$path = "/{$resize}/{$width}/{$height}/{$gravity}/{$enlarge}/{$encodedUrl}.{$extension}";
$path = "/rs:{$resize}:{$width}:{$height}:{$enlarge}/g:{$gravity}/{$encodedUrl}.{$extension}";
$signature = rtrim(strtr(base64_encode(hash_hmac('sha256', $saltBin.$path, $keyBin, true)), '+/', '-_'), '=');

View File

@ -14,7 +14,7 @@ encoded_url = base64.urlsafe_b64encode(url).rstrip(b"=").decode()
# You can trim padding spaces to get good-looking url
encoded_url = '/'.join(textwrap.wrap(encoded_url, 16))
path = "/{resize}/{width}/{height}/{gravity}/{enlarge}/{encoded_url}.{extension}".format(
path = "/rs:{resize}:{width}:{height}:{enlarge}/g:{gravity}/{encoded_url}.{extension}".format(
encoded_url=encoded_url,
resize="fill",
width=300,

View File

@ -16,7 +16,7 @@ gravity = "no"
enlarge = 1
extension = "png"
path = "/#{resize}/#{width}/#{height}/#{gravity}/#{enlarge}/#{encoded_url}.#{extension}"
path = "/rs:#{resize}:#{width}:#{height}:#{enlarge}/g:#{gravity}/#{encoded_url}.#{extension}"
digest = OpenSSL::Digest.new("sha256")
# You can trim padding spaces to get good-looking url

View File

@ -56,7 +56,7 @@ let originalUrl = "http://img.example.com/pretty/image.jpg";
let encodedUrl = customBase64(input: Data(originalUrl.utf8))
let format = "png";
let partialPath = "/\(resizing)/\(width)/\(height)/\(gravity)/\(enlarge)/\(encodedUrl).\(format)"
let partialPath = "/rs:\(resizing):\(width):\(height):\(enlarge)/g:\(gravity)/\(encodedUrl).\(format)"
let toSign = salt + partialPath.utf8
let signature = toSign.hmac256(key: key)

View File

@ -20,6 +20,8 @@ func TestMain(m *testing.M) {
func (s *MainTestSuite) SetupTest() {
s.oldConf = conf
// Reset presets
conf.Presets = make(presets)
}
func (s *MainTestSuite) TearDownTest() {

View File

@ -1062,7 +1062,7 @@ func defaultProcessingOptions(headers *processingHeaders) (*processingOptions, e
return po, nil
}
func parsePathAdvanced(parts []string, headers *processingHeaders) (string, *processingOptions, error) {
func parsePathOptions(parts []string, headers *processingHeaders) (string, *processingOptions, error) {
po, err := defaultProcessingOptions(headers)
if err != nil {
return "", po, err
@ -1115,48 +1115,6 @@ func parsePathPresets(parts []string, headers *processingHeaders) (string, *proc
return url, po, nil
}
func parsePathBasic(parts []string, headers *processingHeaders) (string, *processingOptions, error) {
if len(parts) < 6 {
return "", nil, fmt.Errorf("Invalid basic URL format arguments: %s", strings.Join(parts, "/"))
}
po, err := defaultProcessingOptions(headers)
if err != nil {
return "", po, err
}
po.ResizingType = resizeTypes[parts[0]]
if err = applyWidthOption(po, parts[1:2]); err != nil {
return "", po, err
}
if err = applyHeightOption(po, parts[2:3]); err != nil {
return "", po, err
}
if err = applyGravityOption(po, strings.Split(parts[3], ":")); err != nil {
return "", po, err
}
if err = applyEnlargeOption(po, parts[4:5]); err != nil {
return "", po, err
}
url, extension, err := decodeURL(parts[5:])
if err != nil {
return "", po, err
}
if len(extension) > 0 {
if err := applyFormatOption(po, []string{extension}); err != nil {
return "", po, err
}
}
return url, po, nil
}
func parsePath(ctx context.Context, r *http.Request) (context.Context, error) {
var err error
@ -1192,10 +1150,8 @@ func parsePath(ctx context.Context, r *http.Request) (context.Context, error) {
if conf.OnlyPresets {
imageURL, po, err = parsePathPresets(parts[1:], headers)
} else if _, ok := resizeTypes[parts[1]]; ok {
imageURL, po, err = parsePathBasic(parts[1:], headers)
} else {
imageURL, po, err = parsePathAdvanced(parts[1:], headers)
imageURL, po, err = parsePathOptions(parts[1:], headers)
}
if err != nil {

View File

@ -123,22 +123,7 @@ func (s *ProcessingOptionsTestSuite) TestParseURLNotAllowedSource() {
require.Error(s.T(), err)
}
func (s *ProcessingOptionsTestSuite) TestParsePathBasic() {
req := s.getRequest("/unsafe/fill/100/200/noea/1/plain/http://images.dev/lorem/ipsum.jpg@png")
ctx, err := parsePath(context.Background(), req)
require.Nil(s.T(), err)
po := getProcessingOptions(ctx)
assert.Equal(s.T(), resizeFill, po.ResizingType)
assert.Equal(s.T(), 100, po.Width)
assert.Equal(s.T(), 200, po.Height)
assert.Equal(s.T(), gravityNorthEast, po.Gravity.Type)
assert.True(s.T(), po.Enlarge)
assert.Equal(s.T(), imageTypePNG, po.Format)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedFormat() {
func (s *ProcessingOptionsTestSuite) TestParsePathFormat() {
req := s.getRequest("/unsafe/format:webp/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -148,7 +133,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedFormat() {
assert.Equal(s.T(), imageTypeWEBP, po.Format)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedResize() {
func (s *ProcessingOptionsTestSuite) TestParsePathResize() {
req := s.getRequest("/unsafe/resize:fill:100:200:1/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -161,7 +146,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedResize() {
assert.True(s.T(), po.Enlarge)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedResizingType() {
func (s *ProcessingOptionsTestSuite) TestParsePathResizingType() {
req := s.getRequest("/unsafe/resizing_type:fill/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -171,7 +156,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedResizingType() {
assert.Equal(s.T(), resizeFill, po.ResizingType)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedSize() {
func (s *ProcessingOptionsTestSuite) TestParsePathSize() {
req := s.getRequest("/unsafe/size:100:200:1/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -183,7 +168,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedSize() {
assert.True(s.T(), po.Enlarge)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedWidth() {
func (s *ProcessingOptionsTestSuite) TestParsePathWidth() {
req := s.getRequest("/unsafe/width:100/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -193,7 +178,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedWidth() {
assert.Equal(s.T(), 100, po.Width)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedHeight() {
func (s *ProcessingOptionsTestSuite) TestParsePathHeight() {
req := s.getRequest("/unsafe/height:100/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -203,7 +188,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedHeight() {
assert.Equal(s.T(), 100, po.Height)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedEnlarge() {
func (s *ProcessingOptionsTestSuite) TestParsePathEnlarge() {
req := s.getRequest("/unsafe/enlarge:1/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -213,7 +198,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedEnlarge() {
assert.True(s.T(), po.Enlarge)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedExtend() {
func (s *ProcessingOptionsTestSuite) TestParsePathExtend() {
req := s.getRequest("/unsafe/extend:1:so:10:20/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -226,7 +211,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedExtend() {
assert.Equal(s.T(), 20.0, po.Extend.Gravity.Y)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedGravity() {
func (s *ProcessingOptionsTestSuite) TestParsePathGravity() {
req := s.getRequest("/unsafe/gravity:soea/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -236,7 +221,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedGravity() {
assert.Equal(s.T(), gravitySouthEast, po.Gravity.Type)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedGravityFocuspoint() {
func (s *ProcessingOptionsTestSuite) TestParsePathGravityFocuspoint() {
req := s.getRequest("/unsafe/gravity:fp:0.5:0.75/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -248,7 +233,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedGravityFocuspoint() {
assert.Equal(s.T(), 0.75, po.Gravity.Y)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedQuality() {
func (s *ProcessingOptionsTestSuite) TestParsePathQuality() {
req := s.getRequest("/unsafe/quality:55/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -258,7 +243,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedQuality() {
assert.Equal(s.T(), 55, po.Quality)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedBackground() {
func (s *ProcessingOptionsTestSuite) TestParsePathBackground() {
req := s.getRequest("/unsafe/background:128:129:130/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -271,7 +256,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedBackground() {
assert.Equal(s.T(), uint8(130), po.Background.B)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedBackgroundHex() {
func (s *ProcessingOptionsTestSuite) TestParsePathBackgroundHex() {
req := s.getRequest("/unsafe/background:ffddee/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -284,7 +269,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedBackgroundHex() {
assert.Equal(s.T(), uint8(0xee), po.Background.B)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedBackgroundDisable() {
func (s *ProcessingOptionsTestSuite) TestParsePathBackgroundDisable() {
req := s.getRequest("/unsafe/background:fff/background:/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -294,7 +279,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedBackgroundDisable() {
assert.False(s.T(), po.Flatten)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedBlur() {
func (s *ProcessingOptionsTestSuite) TestParsePathBlur() {
req := s.getRequest("/unsafe/blur:0.2/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -304,7 +289,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedBlur() {
assert.Equal(s.T(), float32(0.2), po.Blur)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedSharpen() {
func (s *ProcessingOptionsTestSuite) TestParsePathSharpen() {
req := s.getRequest("/unsafe/sharpen:0.2/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -313,7 +298,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedSharpen() {
po := getProcessingOptions(ctx)
assert.Equal(s.T(), float32(0.2), po.Sharpen)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedDpr() {
func (s *ProcessingOptionsTestSuite) TestParsePathDpr() {
req := s.getRequest("/unsafe/dpr:2/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -322,7 +307,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedDpr() {
po := getProcessingOptions(ctx)
assert.Equal(s.T(), 2.0, po.Dpr)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedWatermark() {
func (s *ProcessingOptionsTestSuite) TestParsePathWatermark() {
req := s.getRequest("/unsafe/watermark:0.5:soea:10:20:0.6/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -336,7 +321,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedWatermark() {
assert.Equal(s.T(), 0.6, po.Watermark.Scale)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedPreset() {
func (s *ProcessingOptionsTestSuite) TestParsePathPreset() {
conf.Presets["test1"] = urlOptions{
urlOption{Name: "resizing_type", Args: []string{"fill"}},
}
@ -375,7 +360,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathPresetDefault() {
assert.Equal(s.T(), 70, po.Quality)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedPresetLoopDetection() {
func (s *ProcessingOptionsTestSuite) TestParsePathPresetLoopDetection() {
conf.Presets["test1"] = urlOptions{
urlOption{Name: "resizing_type", Args: []string{"fill"}},
}
@ -394,7 +379,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedPresetLoopDetection()
require.ElementsMatch(s.T(), po.UsedPresets, []string{"test1", "test2"})
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedCachebuster() {
func (s *ProcessingOptionsTestSuite) TestParsePathCachebuster() {
req := s.getRequest("/unsafe/cachebuster:123/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)
@ -404,7 +389,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedCachebuster() {
assert.Equal(s.T(), "123", po.CacheBuster)
}
func (s *ProcessingOptionsTestSuite) TestParsePathAdvancedStripMetadata() {
func (s *ProcessingOptionsTestSuite) TestParsePathStripMetadata() {
req := s.getRequest("/unsafe/strip_metadata:true/plain/http://images.dev/lorem/ipsum.jpg")
ctx, err := parsePath(context.Background(), req)