diff options
| author | ivar <i@oiee.no> | 2026-04-04 16:43:33 +0200 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2026-04-04 16:43:33 +0200 |
| commit | 0baeaa05d82b83cc290936b1c3068a7f0761efb5 (patch) | |
| tree | ee7ea050ca3c4ac795912459c8e114bbf1478c5c /internal/media | |
| parent | 3ffe741c0b8032f65d3b5e1770b840dc34bbb72f (diff) | |
| download | nebbet.no-0baeaa05d82b83cc290936b1c3068a7f0761efb5.tar.xz nebbet.no-0baeaa05d82b83cc290936b1c3068a7f0761efb5.zip | |
refactor: consolidate format validation into switch default
Diffstat (limited to 'internal/media')
| -rw-r--r-- | internal/media/process.go | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/internal/media/process.go b/internal/media/process.go index bb3ac89..ac94155 100644 --- a/internal/media/process.go +++ b/internal/media/process.go @@ -11,10 +11,6 @@ import ( // // width <= 0 means no resize. format must be "webp" or "jpeg". func ConvertAndResize(src string, width int, format string) ([]byte, error) { - if format != "webp" && format != "jpeg" { - return nil, fmt.Errorf("unsupported format %q: must be webp or jpeg", format) - } - img, err := vips.NewImageFromFile(src) if err != nil { return nil, fmt.Errorf("load image %s: %w", src, err) @@ -41,6 +37,7 @@ func ConvertAndResize(src string, width int, format string) ([]byte, error) { return nil, fmt.Errorf("export jpeg: %w", err) } return buf, nil + default: + return nil, fmt.Errorf("unsupported format %q: must be webp or jpeg", format) } - return nil, fmt.Errorf("unsupported format %q", format) } |
