im-local

Self-hosted image transformations over HTTP: resize, crop around faces and features, colour work, compositing, and background removal. Output formats are negotiated per client. Everything below is rendered live by this server.

Source

source image
drop an image here, or

Client capabilities

The service picks an output format from what the client accepts. These switches change the Accept header used for every request on this page, so you can see what a different device would get.

Playground

result

        
        
      

Request

GET /process?url=<source>&im=<transformations>[&out=auto][&prefer=avif,webp,jxl][&quality=90]
parameterdescription
urlAbsolute http or https URL of the pristine image. Hosts are restricted by configuration.
imTransformation chain, separated by ;, applied left to right.
imopAlias for im.
width, heightShortcut for a resize.
outjpeg, png, webp, avif, jxl are encoded as asked. auto negotiates. Omitted keeps the source format.
preferPreference order for negotiation, for example avif,webp,jxl. The first format the client accepts wins.
quality1 to 100, default 90. Mapped per encoder.
nocacheRecompute instead of reading the cache.

Derivatives are cached in /app/cache for 24h0m0s, keyed by source, transformation chain, format, and quality. Responses carry ETag, Cache-Control and Vary: Accept; the X-Cache chip on each card shows whether it came from disk. A negotiated format switches to PNG rather than dropping an alpha channel.

Output format and encoding

Source format

No out parameter keeps the format of the pristine image.

Source format
(no transformation)

WebP

Widely supported, carries an alpha channel.

WebP
out=webp

AVIF

Usually the smallest of the three at the same quality, and the slowest to encode.

AVIF
out=avif

JPEG XL

Supported by few browsers today; useful when the client is known.

JPEG XL
out=jxl

Negotiated

out=auto picks the first format the client accepts, from avif, webp, jxl.

Negotiated
out=auto

Preference order

prefer sets that order explicitly, here webp before avif.

Preference order
out=auto&prefer=webp,avif,jxl

Quality

Quality is mapped per encoder; 1 to 100, default 90.

Quality
quality=20

Transparency is kept

A negotiated format switches to PNG when a transformation adds an alpha channel.

Transparency is kept
im=Resize,width=300;Rotate,degrees=15

Resizing and scaling

Resize

Resize=(width,height) resizes to exact dimensions.

Resize
im=Resize=(300,150)

Resize, one dimension

Omit a dimension to keep the aspect ratio.

Resize, one dimension
im=Resize,width=220

Scale

Scale by a factor of the current size.

Scale
im=Scale,width=0.25,height=0.25

Fit and Fill

Fit inside the box and fill the rest with a blurred copy.

Fit and Fill
im=FitAndFill=(320,320)

Cropping

Crop

Crop a rectangle, optionally with a gravity.

Crop
im=Crop,rect=(0,0,300,300),gravity=Center

Crop with expansion

allowExpansion pads with transparency instead of clamping.

Crop with expansion
im=Crop,size=(1200,300),allowExpansion&out=png

Aspect Crop

Crop to an aspect ratio; xPosition/yPosition pick the kept region.

Aspect Crop
im=AspectCrop=(16,9),xPosition=.5,yPosition=.3

Aspect Crop, expanded

allowExpansion adds transparent pixels instead of cropping.

Aspect Crop, expanded
im=AspectCrop=(1,1),allowExpansion&out=png

Relative Crop

Shrink or expand each edge relative to the current size.

Relative Crop
im=RelativeCrop,north=100,south=100,east=50,west=50

Region of Interest Crop

Crop around a focal point.

Region of Interest Crop
im=RegionOfInterestCrop=(300,300),regionOfInterest=(300,220)

Feature Crop

Crop around the most prominent features.

Feature Crop
im=FeatureCrop,size=(300,300)

Face Crop

Crop around detected faces.

Face Crop
im=FaceCrop,width=300,height=300

Smart Crop

Faces when present, features otherwise.

Smart Crop
im=SmartCrop,size=(300,300)

Trim

Trim uniform edges.

Trim
im=Trim,tolerance=0.05;Resize,width=300

Orientation and distortion

Mirror

Flip horizontally or vertically.

Mirror
im=Mirror,horizontal;Resize,width=300

Rotate

Positive degrees rotate clockwise; the canvas grows.

Rotate
im=Resize,width=300;Rotate,degrees=13&out=png

Shear

Slant into a parallelogram.

Shear
im=Resize,width=300;Shear,x=0.3&out=png

Goop

Distort the image; chaos ranges from 0 to 1.

Goop
im=Resize,width=300;Goop,chaos=1

Color

Grayscale

Render in shades of gray.

Grayscale
im=Resize,width=300;Grayscale

Contrast

Values above 1 increase contrast.

Contrast
im=Resize,width=300;Contrast,contrast=1.6

HSL

Hue rotation plus saturation and lightness multipliers.

HSL
im=Resize,width=300;HSL,hue=0.2,saturation=1.6,lightness=1.1

HSV

Same idea using value instead of lightness.

HSV
im=Resize,width=300;HSV,hue=0.5,saturation=2,value=1

Mono Hue

Force every hue to one value, in degrees.

Mono Hue
im=Resize,width=300;MonoHue,hue=210

Max Colors

Reduce the palette to shrink the file.

Max Colors
im=Resize,width=300;MaxColors,colors=8

Background Color

Fill transparency with a color.

Background Color
im=Resize,width=300;Rotate,degrees=13;BackgroundColor,color=00ff00

Transparency

Opacity

Multiplier on the current opacity.

Opacity
im=Resize,width=300;Opacity=0.35&out=png

Chroma Key

Remove a hue range, green by default.

Chroma Key
im=Resize,width=300;ChromaKey,hue=40,hueTolerance=0.15&out=png

Remove Color

Remove one color with tolerance and feathering.

Remove Color
im=Resize,width=300;RemoveColor,color=e8e2d8,tolerance=0.08,feather=0.05&out=png

Background removal

Background Remove

Cut the subject out with a locally executed segmentation model, no hosted service involved.

Background Remove
im=Resize,width=320;BackgroundRemove,fallback=color&out=png

Hard edges

threshold turns the soft mask into a firmer cut-out; feather controls the ramp.

Hard edges
im=Resize,width=320;BackgroundRemove,threshold=0.6,feather=0.05,fallback=color&out=png

Replace the background

Chain BackgroundColor to drop the subject onto a flat colour.

Replace the background
im=Resize,width=320;BackgroundRemove,fallback=color;BackgroundColor,color=0b7285

Background removal without a model

Colour method

method=color needs no model at all. It suits clean backdrops like this one, not busy scenes.

Colour method
im=Resize,width=320;BackgroundRemove,method=color&out=png

Colour method, replaced

The same cut-out dropped onto a flat colour.

Colour method, replaced
im=Resize,width=320;BackgroundRemove,method=color;BackgroundColor,color=0b7285

Remove Color

Remove one specific colour instead of learning it from the border.

Remove Color
im=Resize,width=320;RemoveColor,color=eceae4,tolerance=0.1,feather=0.05&out=png

Detail

Blur

Gaussian blur; higher is blurrier.

Blur
im=Resize,width=300;Blur=4

Unsharp Mask

Sharpen edges and detail.

Unsharp Mask
im=Resize,width=300;UnsharpMask,gain=3

Compositing

Composite

Overlay another image, for example a watermark.

Composite
im=Resize,width=300;Composite,image=(url={sample}),gravity=SouthEast,scale=0.1,opacity=0.7

Composite, underlay

placement=under puts the source image on top.

Composite, underlay
im=Resize,width=300;Rotate,degrees=10;Composite,image=(url={sample}),placement=under,gravity=Center,scale=0.4

Append

Place another image beside the source.

Append
im=Resize,width=200;Append,image=(url={sample}),gravity=East

Conditions

If Dimension

Branch on the current width or height.

If Dimension
im=IfDimension,value=500,dimension=width,greaterThan=$(Resize=(300,200)),lessThan=$(Grayscale)

If Orientation

Branch on portrait, landscape, or square.

If Orientation
im=IfOrientation,landscape=$(Resize=(300,169)),portrait=$(Resize=(169,300)),square=$(Resize=(300,300))

Chaining and legacy parameters

Chained transformations

Transformations run left to right, separated by semicolons.

Chained transformations
im=AspectCrop=(1,1);Resize,width=300;Grayscale;Blur=2

Legacy imop

The imop parameter is an alias for im.

Legacy imop
imop=Resize,width=300,height=150

Legacy width and height

Bare width and height still resize.

Legacy width and height
width=300&height=150