From a1e81bb21fb364594d67c56cd4af4e2684fcd4c6 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Sun, 13 Oct 2019 09:06:27 -0700 Subject: [PATCH] add svg output support, but only with primitive --- data.go | 5 +++-- imageproxy.go | 3 +++ transform.go | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/data.go b/data.go index 54c172b..61efaea 100644 --- a/data.go +++ b/data.go @@ -19,6 +19,7 @@ const ( optFlipHorizontal = "fh" optFormatJPEG = "jpeg" optFormatPNG = "png" + optFormatSVG = "svg" optFormatTIFF = "tiff" optPrimitivePrefix = "p" optRotatePrefix = "r" @@ -70,7 +71,7 @@ type Options struct { // will always be overwritten by the value of Proxy.ScaleUp. ScaleUp bool - // Desired image format. Valid values are "jpeg", "png", "tiff". + // Desired image format. Valid values are "jpeg", "png", "svg", "tiff". Format string // Crop rectangle params @@ -256,7 +257,7 @@ func ParseOptions(str string) Options { options.FlipHorizontal = true case opt == optScaleUp: // this option is intentionally not documented above options.ScaleUp = true - case opt == optFormatJPEG, opt == optFormatPNG, opt == optFormatTIFF: + case opt == optFormatJPEG, opt == optFormatPNG, opt == optFormatSVG, opt == optFormatTIFF: options.Format = opt case opt == optSmartCrop: options.SmartCrop = true diff --git a/imageproxy.go b/imageproxy.go index 8a37a56..3d53639 100644 --- a/imageproxy.go +++ b/imageproxy.go @@ -263,6 +263,9 @@ func peekContentType(p *bufio.Reader) string { if err != nil && err != bufio.ErrBufferFull && err != io.EOF { return "" } + if bytes.HasPrefix(byt, []byte("