Implement size and compression print

This commit is contained in:
2024-08-29 11:43:19 +02:00
parent 32ad037601
commit 0c12f1f1b6

View File

@@ -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 {