(c *Context)
| 1 | package processing |
| 2 | |
| 3 | func (p *Processor) scale(c *Context) error { |
| 4 | if c.WScale == 1 && c.HScale == 1 { |
| 5 | return nil |
| 6 | } |
| 7 | |
| 8 | wscale, hscale := c.WScale, c.HScale |
| 9 | |
| 10 | if (c.Angle+c.PO.Rotate())%180 == 90 { |
| 11 | wscale, hscale = hscale, wscale |
| 12 | } |
| 13 | |
| 14 | // Save current colorspace |
| 15 | cs := c.Img.Type() |
| 16 | |
| 17 | // Convert to linear colorspace if needed |
| 18 | if p.config.UseLinearColorspace { |
| 19 | // We need this to keep colors consistent after processing |
| 20 | if err := c.Img.ImportColourProfile(); err != nil { |
| 21 | return err |
| 22 | } |
| 23 | |
| 24 | // Convert to linear colorspace |
| 25 | if err := c.Img.LinearColourspace(); err != nil { |
| 26 | return err |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | if err := c.Img.Resize(wscale, hscale); err != nil { |
| 31 | return err |
| 32 | } |
| 33 | |
| 34 | // Convert back to original colorspace if we used linear during processing |
| 35 | if p.config.UseLinearColorspace { |
| 36 | return c.Img.Colorspace(cs) |
| 37 | } |
| 38 | |
| 39 | return nil |
| 40 | } |
nothing calls this directly
no test coverage detected