logging each steps
This commit is contained in:
parent
09b64a7fad
commit
b7053c68aa
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.jpg
|
||||
*.png
|
15
blend.go
15
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
|
||||
|
3
fs.go
3
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))
|
||||
|
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user