Thumb3x

Modern Image Processing for MODX 3

This component was written to fill a gap in the MODX 3 ecosystem, where modern and reliable tools for working with images are virtually absent. Most existing solutions have not been updated in over 10 years and do not take advantage of the new system version.

Key Features

  • Modern Formats: On-the-fly conversion to WebP and AVIF.
  • Advanced Engine: Based on the high-performance Glide 3.0.1 library.
  • MODX 3 Integration: Full support for Media Sources and System Settings.
  • Flexible Processing: Filters, effects, watermarks, and precise positioning.
  • Fenom Support: Convenient snippet calls by passing parameters as arrays.
  • Cache Management: Logging of generated files in the database with a convenient grid in the manager.

Basic Usage

<img src="[[!Thumb3x? &input=`path/to/image.jpg` &options=`w=300&h=200`]]" alt="">

Main Snippet Parameters

Parameter Alias Description Example
input i (Required) Path to the source image. &input=`image.jpg`
options o String or array (for Fenom) with processing parameters for Glide. &options=`w=400&fit=crop`
sourceId The Media Source ID for the source image. Defaults to the value from System Settings. &sourceId=`2`
watermark Path to the watermark file. Activates the watermarking functionality. &watermark=`assets/logo.png`
quality q (Overridden by `&options`) Default quality. &quality=`75`
format fm (Overridden by `&options`) Default format. &format=`webp`
Important: Any parameters (`q`, `fm`, etc.) specified inside the &options string always have the highest priority.

Processing Parameters Reference (`&options`)

Sizing & Orientation

ParameterKeyDescriptionExample
WidthwThe width of the output image in pixels.w=300
HeighthThe height of the output image in pixels.h=200
FitfitHow the image is fitted to its target dimensions. Main values: contain, max, stretch, crop.fit=crop
CropcropPrecise cropping: width,height,x,y.crop=200,150,20,50
DPRdprDevice Pixel Ratio. dpr=2 will return an image twice as large for Retina displays.dpr=2
OrientationorRotates the image. Values: auto, 0, 90, 180, 270.or=90
FlipflipFlips the image. Values: v (vertically), h (horizontally), both.flip=h

Adjustments & Effects

ParameterKeyDescriptionExample
BrightnessbriAdjusts brightness (-100 to +100).bri=20
ContrastconAdjusts contrast (-100 to +100).con=-30
GammagamGamma correction (0.1 to 9.99).gam=2.2
SharpensharpSharpens the image (0 to 100).sharp=10
BlurblurApplies a Gaussian blur (0 to 100).blur=15
PixelatepixelApplies a pixelation effect (0 to 1000).pixel=10
FilterfiltApplies a filter: greyscale or sepia.filt=greyscale

Background & Border

ParameterKeyDescriptionExample
BackgroundbgSets the background color. Format: RRGGBB.bg=CCCCCC
BorderborderAdds a border. Format: width,color,type. Type: overlay or shrink.border=5,000000,overlay

Watermarks

ParameterKeyDescriptionExample
Pathmark(Required) The watermark's filename.mark=logo.png
WidthmarkwWatermark width (in px or %).markw=15w
HeightmarkhWatermark height (in px or %).markh=50
X-OffsetmarkxHorizontal offset (negative values from the right edge).markx=-20
Y-OffsetmarkyVertical offset (negative values from the bottom edge).marky=-20
PaddingmarkpadPadding on all sides.markpad=10
PositionmarkposPosition: top-left, center, bottom-right, etc.markpos=top-left
AlphamarkalphaWatermark opacity (0-100).markalpha=50

Output Format

ParameterKeyDescriptionValuesExample
FormatfmThe output image format.jpg, png, gif, webp, aviffm=webp
QualityqQuality for `jpg`, `webp`, `avif`.`0` to `100`q=80

Detailed Usage Examples

Example 1: Applying a Watermark (Standard MODX Call)

Task: Apply logo.png to the bottom-right corner with padding and semi-transparency.

<img src="[[!Thumb3x?
    &input=`portfolio/image-01.jpg`
    &watermark=`assets/watermark/logo.png`
    &options=`w=1200&mark=logo.png&markpos=bottom-right&markpad=30&markalpha=50`
]]" alt="Portfolio with watermark">

Example 2: Advanced Fenom Call

Task: Resize the image, crop it to a square, apply a sepia filter, and convert to WebP with 75 quality.

{var $params = [
    'w' => 300,
    'h' => 300,
    'fit' => 'crop',
    'filt' => 'sepia',
    'q' => 75,
    'fm' => 'webp'
]}

<img src="{'!Thumb3x' | snippet : [
    'input' => 'path/to/avatar.jpg',
    'options' => $params
]}" alt="Avatar in sepia">