Last active
November 11, 2018 13:41
-
-
Save mamaz/f730f3fa007029d020c28dda34ab92b2 to your computer and use it in GitHub Desktop.
Resize Image sequentially
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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