rotate_and_flip.go 460 B

123456789101112131415161718192021
  1. package processing
  2. import (
  3. "github.com/imgproxy/imgproxy/v3/imagedata"
  4. "github.com/imgproxy/imgproxy/v3/options"
  5. "github.com/imgproxy/imgproxy/v3/vips"
  6. )
  7. func rotateAndFlip(pctx *pipelineContext, img *vips.Image, po *options.ProcessingOptions, imgdata *imagedata.ImageData) error {
  8. if err := img.Rotate(pctx.angle); err != nil {
  9. return err
  10. }
  11. if pctx.flip {
  12. if err := img.Flip(); err != nil {
  13. return err
  14. }
  15. }
  16. return img.Rotate(po.Rotate)
  17. }