Chuyển tới nội dung chính

URL Format & Parameters

Two URL Styles

PreviewProxy supports two request styles: path-style and query-style.

Path-style

Parameters are embedded directly in the URL path, before the image URL:

http://your-host/<params>/<image_url>
http://your-host/w=400,h=300,format=webp/https://example.com/image.jpg

Multiple parameters are separated by commas. The image URL follows after a /.

If no transforms are needed, the params segment can be omitted entirely:

http://your-host/https://example.com/image.jpg

Query-style

Parameters are passed as standard HTTP query string params to the /proxy endpoint:

http://your-host/proxy?url=<image_url>&param=value&...
http://your-host/proxy?url=https://example.com/image.jpg&w=400&h=300&format=webp

Path Parameter Syntax

Path-style supports three equivalent syntaxes for each parameter. All can be freely mixed in the same request:

SyntaxExampleNotes
key=valuew=400,h=300Same keys as query-style
key:valuew:400,h:300Alternative separator
Shorthand400x300, q80, r90Compact notation for common params

Shorthand tokens

ShorthandEquivalentDescription
WxHw=W,h=HWidth and height together (e.g. 300x200)
qNq=NQuality (e.g. q80)
rNrotate=NRotation (e.g. r90)
containfit=containFit mode
coverfit=coverFit mode
cropfit=cropFit mode
webpformat=webpOutput format (works for all formats)
fliphflip=hHorizontal flip
flipvflip=vVertical flip
grayscalegrayscale=1Enable grayscale
gif_animgif_anim=allEnable animated GIF (all frames)
gif_afgif_af=1Apply transforms to frame range only

Mixed syntax example

These three requests are equivalent:

/300x200,webp,q80/https://example.com/image.jpg
/w=300,h=200,format=webp,q=80/https://example.com/image.jpg
/w:300,h:200,format:webp,q:80/https://example.com/image.jpg

Supported Source URL Schemes

SchemeExample
HTTP/HTTPShttps://example.com/image.jpg
S3s3:/path/to/image.jpg
Local filesystemlocal:/path/to/image.jpg
Aliasmycdn:/path/to/image.jpg
thông tin

Percent-encoding is supported in the image URL segment. For example, spaces and special characters in filenames can be encoded as %20, %2B, etc.


Parameters Reference

ParamTypeDescription
wintegerOutput width in pixels (max 8192)
hintegerOutput height in pixels (max 8192)
fitstringResize mode: contain, cover, or crop (default: contain)
formatstringOutput format: webp, jpeg, png, avif, gif, bmp, tiff, ico, jxl
qintegerQuality 1-100 for JPEG and WebP (default: encoder default)
rotateintegerClockwise rotation: 90, 180, or 270
flipstringFlip axis: h (horizontal) or v (vertical)
blurfloatGaussian blur radius 0-100
grayscaleboolConvert to grayscale: true or 1
brightintegerBrightness adjustment -255 to 255
contrastintegerContrast adjustment -255 to 255
wmstringWatermark image URL (supports http, https, s3:, local:)
sigstringHMAC-SHA256 signature (required when HMAC_KEY is set)
gif_animstringGIF frame range: all, N, N-M, -N (last N frames)
gif_afboolApply transforms to gif_anim range only, return all frames
seekstringVideo thumbnail seek: N (seconds), Nr (ratio 0-1), auto (middle)

Examples

Resize to fixed dimensions (path-style)

/w=800,h=600/https://example.com/photo.jpg

Convert to WebP with quality (path-style shorthand)

/webp,q85/https://example.com/photo.jpg

Resize, convert format, and set quality (mixed shorthand)

/400x300,webp,q80/https://example.com/photo.jpg

Resize with cover fit (path-style)

/w=400,h=400,fit=cover/https://example.com/photo.jpg

Rotate and flip (path-style)

/rotate=90,flip=h/https://example.com/photo.jpg

Apply blur and grayscale (path-style)

/blur=3,grayscale=1/https://example.com/photo.jpg

Brightness and contrast adjustment (path-style)

/bright=30,contrast=20/https://example.com/photo.jpg

Overlay a watermark (path-style)

/wm=https://example.com/watermark.png/https://example.com/photo.jpg

Query-style equivalent

/proxy?url=https://example.com/photo.jpg&w=400&h=300&format=webp&q=80

S3 source image (path-style)

/w=400,format=webp/s3:/images/photo.jpg

All transforms combined (path-style shorthand)

/800x600,cover,webp,q85,blur:1,bright:10/https://example.com/photo.jpg
mẹo

Parameters can be specified in any order. Only include the parameters you need - unspecified parameters use their defaults or are skipped entirely.

cảnh báo

The sig parameter is required when HMAC_KEY is configured on the server. Requests without a valid signature will be rejected. See the security documentation for details on generating signatures.