Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exposed palette from GET endpoints #380

Merged
merged 1 commit into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ Image measures are always in pixels, unless otherwise indicated.
- **areaheight** `int` - Width area to extract. Example: `300`
- **quality** `int` - JPEG image quality between 1-100. Defaults to `80`
- **compression** `int` - PNG compression level. Default: `6`
- **palette** `bool` - Enable 8-bit quantisation. Works with only PNG images. Default: `false`
- **rotate** `int` - Image rotation angle. Must be multiple of `90`. Example: `180`
- **factor** `int` - Zoom factor level. Example: `2`
- **margin** `int` - Text area margin for watermark. Example: `50`
Expand Down Expand Up @@ -755,6 +756,7 @@ Resize an image by width or height. Image aspect ratio is maintained
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- aspectratio `string`
- palette `bool`

#### GET | POST /enlarge
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -784,6 +786,7 @@ Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
- minampl `float`
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- palette `bool`

#### GET | POST /extract
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -817,6 +820,7 @@ Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- aspectratio `string`
- palette `bool`

#### GET | POST /zoom
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -848,6 +852,7 @@ Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- aspectratio `string`
- palette `bool`

#### GET | POST /thumbnail
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -877,6 +882,7 @@ Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- aspectratio `string`
- palette `bool`

#### GET | POST /fit
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -909,6 +915,7 @@ The width and height specify a maximum bounding box for the image.
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- aspectratio `string`
- palette `bool`

#### GET | POST /rotate
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -946,6 +953,7 @@ Returns a new image with the same size and format as the input image.
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- aspectratio `string`
- palette `bool`

#### GET | POST /flip
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -974,6 +982,7 @@ Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- aspectratio `string`
- palette `bool`

#### GET | POST /flop
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -1002,6 +1011,7 @@ Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- aspectratio `string`
- palette `bool`

#### GET | POST /convert
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -1029,6 +1039,7 @@ Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- aspectratio `string`
- palette `bool`

#### GET | POST /pipeline
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -1152,6 +1163,7 @@ Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
- minampl `float`
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- palette `bool`

#### GET | POST /watermarkimage
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -1182,6 +1194,7 @@ Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
- minampl `float`
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- palette `bool`

#### GET | POST /blur
Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
Expand Down Expand Up @@ -1210,6 +1223,7 @@ Accepts: `image/*, multipart/form-data`. Content-Type: `image/*`
- field `string` - Only POST and `multipart/form` payloads
- interlace `bool`
- aspectratio `string`
- palette `bool`

## Logging

Expand Down
2 changes: 2 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type IsDefinedField struct {
NoProfile bool
StripMetadata bool
Interlace bool
Palette bool
}

// PipelineOperation represents the structure for an operation field.
Expand Down Expand Up @@ -142,6 +143,7 @@ func BimgOptions(o ImageOptions) bimg.Options {
Type: ImageType(o.Type),
Rotate: bimg.Angle(o.Rotate),
Interlace: o.Interlace,
Palette: o.Palette,
}

if len(o.Background) != 0 {
Expand Down
7 changes: 7 additions & 0 deletions params.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var paramTypeCoercions = map[string]Coercion{
"operations": coerceOperations,
"interlace": coerceInterlace,
"aspectratio": coerceAspectRatio,
"palette": coercePalette,
}

func coerceTypeInt(param interface{}) (int, error) {
Expand Down Expand Up @@ -343,6 +344,12 @@ func coerceInterlace(io *ImageOptions, param interface{}) (err error) {
return err
}

func coercePalette(io *ImageOptions, param interface{}) (err error) {
io.Palette, err = coerceTypeBool(param)
io.IsDefinedField.Palette = true
return err
}

func buildParamsFromOperation(op PipelineOperation) (ImageOptions, error) {
var options ImageOptions

Expand Down