-
-
Notifications
You must be signed in to change notification settings - Fork 8
Image options
Norbert Boros edited this page Sep 22, 2023
·
1 revision
With Cloudflare Image Resizing, enhancing your images goes beyond just quicker delivery and compression.
Starting from version 2.0.0, features such as gravity and sharpening are configurable. Detailed explanations for these options can be found in the worker code:
// Browser-level support for lazy loading images.
// Browsers that do not support the loading attribute simply ignore it without side effects.
IMAGE_LAZY_LOAD: true,
// Quality determines the trade-off between image file size and visual quality.
// Range 1-100
IMAGE_QUALITY: 90,
// Resize method determines how the image should be scaled or cropped.
// Only used when the width and height can be retrieved.
// Values: 'scale-down', 'contain', 'cover', 'crop', 'pad'.
IMAGE_FIT: 'crop',
// When cropping with fit: "cover" and fit: "crop", this parameter defines the side or point that should not be cropped.
// Mode 'auto' selects focal point based on saliency detection (using maximum symmetric surround algorithm)
IMAGE_GRAVITY: 'auto',
// Specifies strength of sharpening filter to apply to the image.
// The value is a floating-point number between 0 (no sharpening, default) and 10 (maximum).
// Note that 1 is a recommended value for downscaled images.
// Range: 0 - 10
IMAGE_SHARPEN: 1,
// Controls amount of invisible metadata (EXIF data) that should be preserved. Color profiles and EXIF rotation are applied to the image even if the metadata is discarded.
// Note that if the Polish feature is enabled, all metadata may have been removed already and this option will have no effect.
// Options: 'keep', 'copyright', 'none'
IMAGE_METADATA: 'none',
Based on my testing, the optimal settings are those in the default configuration. If you'd like to disable any of them, simply set their values to 'undefined' as demonstrated:
IMAGE_GRAVITY: undefined,
This will omit the specific option.