mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-04-28 06:16:25 +02:00
add svg output support, but only with primitive
This commit is contained in:
parent
b951a9ccc3
commit
a1e81bb21f
3 changed files with 17 additions and 2 deletions
11
transform.go
11
transform.go
|
|
@ -65,6 +65,11 @@ func Transform(img []byte, opt Options) ([]byte, error) {
|
|||
format = "jpeg"
|
||||
}
|
||||
|
||||
if opt.Format == "svg" && opt.Primitive.Count == 0 {
|
||||
// svg output only supported with primitive transform
|
||||
opt.Format = ""
|
||||
}
|
||||
|
||||
if opt.Format != "" {
|
||||
format = opt.Format
|
||||
}
|
||||
|
|
@ -109,6 +114,12 @@ func Transform(img []byte, opt Options) ([]byte, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "svg":
|
||||
o := opt // copy
|
||||
o.Primitive.Count = 0
|
||||
m = transformImage(m, o)
|
||||
model := transformPrimitive(m, opt)
|
||||
buf.WriteString(model.SVG())
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported format: %v", format)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue