ImageTransformStrategy
ImageTransformStrategy
An injectable strategy which is used to determine the parameters for transforming an image. This can be used to implement custom image transformation logic, for example to limit transform parameters to a known set of presets.
This is set via the imageTransformStrategy
option in the AssetServerOptions. Multiple
strategies can be defined and will be executed in the order in which they are defined.
If a strategy throws an error, the image transformation will be aborted and the error will be logged, with an HTTP 400 response sent to the client.
interface ImageTransformStrategy extends InjectableStrategy {
getImageTransformParameters(
args: GetImageTransformParametersArgs,
): Promise<ImageTransformParameters> | ImageTransformParameters;
}
- Extends:
InjectableStrategy
getImageTransformParameters
(args: GetImageTransformParametersArgs) => Promise<ImageTransformParameters> | ImageTransformParameters
Given the input parameters, return the parameters which should be used to transform the image.
ImageTransformParameters
Parameters which are used to transform the image.
interface ImageTransformParameters {
width: number | undefined;
height: number | undefined;
mode: ImageTransformMode | undefined;
quality: number | undefined;
format: ImageTransformFormat | undefined;
fpx: number | undefined;
fpy: number | undefined;
preset: string | undefined;
}
width
number | undefined
height
number | undefined
mode
ImageTransformMode | undefined
quality
number | undefined
format
ImageTransformFormat | undefined
fpx
number | undefined
fpy
number | undefined
preset
string | undefined
GetImageTransformParametersArgs
The arguments passed to the getImageTransformParameters
method of an ImageTransformStrategy.
interface GetImageTransformParametersArgs {
req: Request;
availablePresets: ImageTransformPreset[];
input: ImageTransformParameters;
}