Micro-service for file storage and processing written in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
517 B

  1. package pipelines
  2. import (
  3. "github.com/disintegration/imaging"
  4. "image"
  5. )
  6. type IExecutableStep interface {
  7. Execute(src image.Image) (image.Image, error)
  8. }
  9. // Resize image
  10. type ResizeImageStep struct {
  11. Step
  12. Options struct {
  13. Width int `json:"width"`
  14. Height int `json:"height"`
  15. Upscale bool `json:"upscale"`
  16. } `json:"options"`
  17. }
  18. func (s ResizeImageStep) Execute(src image.Image) (image.Image, error) {
  19. src = imaging.Resize(src, s.Options.Width, s.Options.Height, imaging.Linear)
  20. return src, nil
  21. }