vectorGuardScale checks if the image is a vector format and downscales it to the maximum allowed resolution if necessary
(c *Context)
| 7 | // vectorGuardScale checks if the image is a vector format and downscales it |
| 8 | // to the maximum allowed resolution if necessary |
| 9 | func (p *Processor) vectorGuardScale(c *Context) error { |
| 10 | if c.ImgData == nil || !c.ImgData.Format().IsVector() { |
| 11 | return nil |
| 12 | } |
| 13 | |
| 14 | maxSrcRes := c.PO.MaxSrcResolution() |
| 15 | |
| 16 | if resolution := c.Img.Width() * c.Img.Height(); resolution > maxSrcRes { |
| 17 | shrink := math.Sqrt(float64(resolution) / float64(maxSrcRes)) |
| 18 | c.VectorBaseShrink = shrink |
| 19 | |
| 20 | if err := c.Img.Load(c.ImgData, shrink, 0, 1); err != nil { |
| 21 | return err |
| 22 | } |
| 23 | } |
| 24 | c.CalcParams() |
| 25 | |
| 26 | return nil |
| 27 | } |
nothing calls this directly
no test coverage detected