Files
media-converter/optimizeImage.go
T
2026-09-06 04:01:51 +02:00

39 lines
609 B
Go

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)
}
}