Signature
CreatePresetOptions
An invalid key or a missing name or transform returns an error before any request is sent.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Save a named transform with client.CreatePreset().
preset, err := client.CreatePreset(ctx, dreep.CreatePresetOptions{
Key: "thumbnail",
Name: "Thumbnail",
Transform: &dreep.Transform{
Width: 200,
Height: 200,
Fit: dreep.FitCover,
Format: dreep.FormatWebP,
},
})
func (c *Client) CreatePreset(ctx context.Context, o dreep.CreatePresetOptions) (*dreep.Preset, error)
CreatePresetOptions| Field | Type | Description |
|---|---|---|
Key | string | Required. Lowercase letters, numbers and underscores. What callers pass as Transform.Preset |
Name | string | Required. Human-readable label |
Transform | *dreep.Transform | Required. The recipe. Set at least a Format or a dimension |
type Preset struct {
ID string
Key string
Name string
Params map[string]any // the stored transform parameters
CreatedAt time.Time
}
client.URL(asset.ID, &dreep.Transform{Preset: "thumbnail"})
client.Upload(ctx, dreep.UploadOptions{
File: f,
Filename: "hero.jpg",
Transform: &dreep.Transform{Preset: "thumbnail"},
})
| Check | Cause |
|---|---|
dreep.IsPaymentRequired(err) | The plan’s preset quota is full |
dreep.IsInvalidRequest(err) | Invalid transform, or a key already in use |