package main import ( "fmt" "os/exec" ) var imageExts = map[string]bool{ ".jpeg": true, ".jpg": true, ".png": true, ".gif": true, ".bmp": true, ".tiff": true, ".tif": true, ".webp": true, } func OptimizeImage(path string) { fmt.Println("optiimg") cmd := exec.Command("mogrify", "-strip", "-interlace", "Plane", "-sampling-factor", "4:2:0", "-resize", "5000x3000", "-quality", "80%", path, ) out, err := cmd.CombinedOutput() if err != nil { fmt.Printf("Error optimizing %s: %v\n%s", path, err, out) } else { markTouched(path) fmt.Printf("Optimized %s\n", path) } }