Last active
July 6, 2020 15:09
-
-
Save rolandvarga/b5086ad1f9c2efcd3830c4c58f434553 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 main() { | |
... | |
for _, f := range r.File { | |
if f.FileInfo().IsDir() { | |
os.MkdirAll(*dest+"/"+f.Name, os.ModePerm) | |
continue | |
} | |
fmt.Printf("converting image: %s\n", f.Name) | |
zipped, err := f.Open() | |
if err != nil { | |
fmt.Printf("error reading '%s': %s\n", f.Name, err.Error()) | |
continue | |
} | |
// grayscale images | |
img, _, err := image.Decode(zipped) | |
if err != nil { | |
fmt.Printf("error decoding image '%s': %s\n", f.Name, err.Error()) | |
continue | |
} | |
gray := image.NewGray(img.Bounds()) | |
for x := 0; x < img.Bounds().Max.X; x++ { | |
for y := 0; y < img.Bounds().Max.Y; y++ { | |
color := img.At(x, y) | |
gray.Set(x, y, color) | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment