Image Policies
The Image Policy feature allows you to define a named set of image processing options that can be used in your URLs. With Image Policy, you can simplify your URLs and make them more human-readable.
#
How to use Image PoliciesTo use an Image Policy in your URL, you simply need to include the policy name as a query parameter. For example:
https://cdn.gjirafa.net/image.jpg?preset=my-preset
The CDN will then apply the processing options defined in the "my-preset" policy to the image.
#
Defining Image PresetsTo define an Image Policy for your project, you can use the Image Policy CRUD API. The API allows you to Create, Read, Update, and Delete Image Policiess.
#
CreateTo create a new Image Policy, you can send a POST request to the API endpoint with the following parameters:
name
: The name of the preset (required), needs to be uniqueprocessingOptions
: An object containing the processing options to be applied (required)comment
: A comment, that you can use to identify your image presets
For example:
curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {token}" \ -d '{ "name": "my-preset", "processingOptions": { "resize": "fit", "width": 640, "height": 360, "gravity": "", "enlarge": false, "blur": 0, "sharpen": 0, "quality": 0, "format": "webp" }, "comment": "used for mobile apps"}' \ "https://cdn.api.gjirafa.tech/projects/{projectID}/image_policies"