Skip to content

Instantly share code, notes, and snippets.

@mamaz
Last active November 11, 2018 13:41
Show Gist options
  • Save mamaz/f730f3fa007029d020c28dda34ab92b2 to your computer and use it in GitHub Desktop.
Save mamaz/f730f3fa007029d020c28dda34ab92b2 to your computer and use it in GitHub Desktop.
Resize Image sequentially
package resizesequential
import (
"Exercise/ResizeImage/lib/resizer"
"Exercise/ResizeImage/lib/types"
"flag"
"fmt"
"os"
"time"
)
// ResizeSequential - Resize sequentially a file input, to several sizes
func ResizeSequential(input string, sizes []types.Size) {
start := time.Now()
if input == "" {
fmt.Printf("No input file \n")
flag.Usage()
os.Exit(0)
}
for _, size := range sizes {
resized, error := resizer.ResizeImage(
input,
size.Width,
size.Height,
)
if error != nil {
fmt.Printf("\nError happens %v", error)
os.Exit(0)
}
fmt.Printf("\nImage resized %v\n", resized)
}
fmt.Println("\nResizeSequential time: ", time.Since(start))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment