Implement size and compression print
This commit is contained in:
11
main.go
11
main.go
@@ -65,7 +65,6 @@ func main() {
|
|||||||
Error.Printf("No encoder found for file: %s", file)
|
Error.Printf("No encoder found for file: %s", file)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Printf("%#v", coder)
|
|
||||||
|
|
||||||
filename := filepath.Base(file)
|
filename := filepath.Base(file)
|
||||||
if *nosafe {
|
if *nosafe {
|
||||||
@@ -82,6 +81,12 @@ func main() {
|
|||||||
Error.Printf("Failed to open file: %v", err)
|
Error.Printf("Failed to open file: %v", err)
|
||||||
return
|
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)
|
log.Printf("Decoding %s", file)
|
||||||
image, err := coder.Decode(filehandle)
|
image, err := coder.Decode(filehandle)
|
||||||
@@ -111,7 +116,7 @@ func main() {
|
|||||||
Error.Printf("Failed to write file %s: %v", newfile, err)
|
Error.Printf("Failed to write file %s: %v", newfile, err)
|
||||||
return
|
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 *rm {
|
||||||
if file == newfile {
|
if file == newfile {
|
||||||
@@ -120,7 +125,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
log.Printf("Removing %s", file)
|
log.Printf("Removing %s", file)
|
||||||
err = os.Remove(file)
|
err = os.Remove(file)
|
||||||
if err!= nil {
|
if err != nil {
|
||||||
Error.Printf("Failed to remove file %v: %v", file, err)
|
Error.Printf("Failed to remove file %v: %v", file, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user