From b7053c68aad85f164c5f2dde1663403903062095 Mon Sep 17 00:00:00 2001 From: Gator Date: Sun, 1 May 2022 09:07:46 +0200 Subject: [PATCH] logging each steps --- .gitignore | 2 ++ blend.go | 15 +++++++++------ fs.go | 3 ++- main_test.go | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a70cd3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.jpg +*.png \ No newline at end of file diff --git a/blend.go b/blend.go index 517badf..2c0a13c 100644 --- a/blend.go +++ b/blend.go @@ -5,6 +5,7 @@ import ( "image" "image/color" "image/jpeg" + "log" "math" "os" "runtime" @@ -13,10 +14,10 @@ import ( // job passed to goroutines. blend color from img1 and img2 at position (x, y) type blendColorJob struct { - X int - Y int - Img1 image.Image - Img2 image.Image + X int + Y int + Img1 image.Image + Img2 image.Image } // new color after blend, to apply at position (x, y) @@ -82,6 +83,8 @@ func (p *blendWorkerPool) SetImageWorker(newImage *image.RGBA) { } func (p *blendWorkerPool) BlendImages(img1 image.Image, img2 image.Image) { + log.Println("Blending the images...") + dimensions := getDimensions(img1, img2) // output image, ready to receive pixel values outImg := image.NewRGBA(dimensions) @@ -103,9 +106,9 @@ func encodeImage(imgData *image.RGBA) { outputFile := fmt.Sprintf("%s/%s", ConfigRegister.OutputDir, "output.jpg") out, _ := os.Create(outputFile) defer out.Close() - fmt.Print("Encoding the image...") + log.Println("Encoding the new image...") jpeg.Encode(out, imgData, nil) - fmt.Println(" Done.") + log.Println("Done.") } // convert RGBA pixel to grayscale diff --git a/fs.go b/fs.go index 10b83da..f0b4873 100644 --- a/fs.go +++ b/fs.go @@ -23,13 +23,14 @@ func loadImage(filename string) image.Image { log.Fatal(err) } + log.Println("Loading :", filename) + return imgData } // Walk through a folder recursively and returns a list of image paths func getImagesList(path string) []string { var imgs []string - err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error { ext := strings.ToLower(filepath.Ext(path)) diff --git a/main_test.go b/main_test.go index 1de5ac2..c16b531 100644 --- a/main_test.go +++ b/main_test.go @@ -1,7 +1,7 @@ package main import ( - "testing" + "testing" ) func TestMain(t *testing.T) {