diff --git a/main.go b/main.go index 45ed0f4..eb386d7 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,7 @@ import ( var codecs = map[string]codec.Coder{ ".jpg": codec.JPGCoder{}, - ".jpeg": codec.JPGCoder{}, + ".jpeg": codec.JPGCoder{}, ".png": codec.PNGCoder{}, ".webp": codec.WebpCoder{}, } @@ -50,7 +50,7 @@ func main() { log.Printf("Using quality: %d", *quality) log.Printf("Transcoding to: %s", *to) log.Printf("Nosafe mode: %v", *nosafe) - log.Printf("Remove mode: %v", *rm) + log.Printf("Remove mode: %v", *rm) var wg sync.WaitGroup for _, file := range flag.Args() { @@ -65,7 +65,6 @@ func main() { Error.Printf("No encoder found for file: %s", file) return } - log.Printf("%#v", coder) filename := filepath.Base(file) if *nosafe { @@ -82,6 +81,12 @@ func main() { Error.Printf("Failed to open file: %v", err) return } + stat, err := filehandle.Stat() + if err != nil { + Error.Printf("Failed to get file stats: %v", err) + return + } + originalSize := stat.Size() log.Printf("Decoding %s", file) image, err := coder.Decode(filehandle) @@ -111,7 +116,7 @@ func main() { Error.Printf("Failed to write file %s: %v", newfile, err) return } - log.Printf("Wrote %d bytes to %s", n, newfile) + log.Printf("Wrote %dKB; Old size: %dKB; Compression: %.2f", n/1024, originalSize/1024, float32(n)/float32(originalSize)) if *rm { if file == newfile { @@ -120,7 +125,7 @@ func main() { } log.Printf("Removing %s", file) err = os.Remove(file) - if err!= nil { + if err != nil { Error.Printf("Failed to remove file %v: %v", file, err) return } @@ -128,4 +133,4 @@ func main() { }(file) } wg.Wait() -} \ No newline at end of file +}