Skip to content

Enums Reference

ResizeType

Controls how images are resized to fit the specified dimensions.

php
use Imsus\ImgProxy\Enums\ResizeType;
Enum ValueFluent MethodDescription
FITcontain()Resize keeping aspect ratio to fit within dimensions (default)
FILLcover()Resize keeping aspect ratio to fill dimensions, cropping overflow
FILL_DOWNfill()Same as fill, but maintains aspect ratio for smaller images
FORCE-Resize without keeping aspect ratio (stretches/distorts)
AUTO-Automatically choose between fit/fill based on orientation

Example

php
// Using fluent method
imgproxy($url)
    ->cover()
    ->width(300)
    ->height(200)
    ->build();

// Using enum directly
imgproxy($url)
    ->setResizeType(ResizeType::FILL)
    ->width(300)
    ->height(200)
    ->build();

OutputExtension

Specifies the output image format.

php
use Imsus\ImgProxy\Enums\OutputExtension;
Enum ValueFluent MethodFormat
JPEGjpg()JPEG format
PNGpng()PNG format
WEBPwebp()WebP format
AVIFavif()AVIF format
GIF-GIF format
ICO-ICO format
SVG-SVG format
HEIC-HEIC format
BMP-BMP format
TIFF-TIFF format

Example

php
// Using fluent method
imgproxy($url)
    ->webp()
    ->quality(85)
    ->build();

// Using enum directly
imgproxy($url)
    ->setExtension(OutputExtension::WEBP)
    ->quality(85)
    ->build();

SourceUrlMode

Controls how the source URL is encoded in the generated URL.

php
use Imsus\ImgProxy\Enums\SourceUrlMode;
Enum ValueDescription
ENCODEDBase64 encode source URL (default, recommended)
PLAINUse plain text URL (for debugging only)

Example

php
imgproxy($url)
    ->setMode(SourceUrlMode::PLAIN)
    ->width(300)
    ->build();

Gravity

Controls which part of the image is kept when using FILL resize type.

php
use Imsus\ImgProxy\Enums\Gravity;
Enum ValueDescription
CECenter (default)
NONorth (top)
SOSouth (bottom)
EAEast (right)
WEWest (left)
NOEANorth-East (top-right)
NOWENorth-West (top-left)
SOEASouth-East (bottom-right)
SOWESouth-West (bottom-left)
AUTOSmart cropping based on image content

Example

php
imgproxy($url)
    ->cover()
    ->width(300)
    ->height(200)
    ->gravity(Gravity::CENTER)
    ->build();

Released under the MIT License.