Last active
July 4, 2020 00:42
-
-
Save rolandvarga/94f7a1ed2fd96fbf91a6e314958e3646 to your computer and use it in GitHub Desktop.
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
func parseExt(path string) string { | |
split := strings.Split(path, ".") | |
return "." + split[len(split)-1] | |
} | |
func today() string { | |
now := time.Now() | |
return now.Format("20060102") | |
} | |
func main() { | |
... | |
newExt := parseExt(f.Name) | |
newFile := *dest + "/" + f.Name[0:len(f.Name)-len(newExt)] + "_GRAYSCALED_" + today() + newExt | |
out, err := os.Create(newFile) | |
if err != nil { | |
fmt.Printf("error creating destination image path '%s': %s\n", newFile, err.Error()) | |
continue | |
} | |
defer out.Close() | |
err = jpeg.Encode(out, gray, nil) | |
if err != nil { | |
fmt.Printf("error saving image at destination '%s': %s\n", newFile, err.Error()) | |
continue | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment