You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"strconv"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) < 5 {
|
|
fmt.Println("Usage: go run main.go <source-file> <number-of-copies> <shit-size> <iterations>")
|
|
return
|
|
}
|
|
|
|
sourceFile := os.Args[1]
|
|
numCopies, err := strconv.Atoi(os.Args[2])
|
|
if err != nil || numCopies <= 0 {
|
|
fmt.Println("Invalid number of copies. Must be a positive integer.")
|
|
return
|
|
}
|
|
|
|
shitSize, err := strconv.ParseInt(os.Args[3], 10, 64) // Parse shitSize as int64
|
|
if err != nil || shitSize <= 0 {
|
|
fmt.Println("Invalid shit size. Must be a positive integer.")
|
|
return
|
|
}
|
|
|
|
iterations, err := strconv.ParseInt(os.Args[4], 10, 8)
|
|
|
|
for i := 1; i <= numCopies; i++ {
|
|
outputFile := fmt.Sprintf("%s_glitched_%d%s",
|
|
stripExtension(sourceFile),
|
|
i,
|
|
filepath.Ext(sourceFile),
|
|
)
|
|
|
|
err := glitchImage(sourceFile, outputFile, shitSize, iterations)
|
|
if err != nil {
|
|
fmt.Printf("Error glitching file %d: %v\n", i, err)
|
|
}
|
|
}
|
|
|
|
fmt.Println("GENREATING GIF YEAHH ")
|
|
// now run ffmpeg to make a gif!
|
|
cmd := exec.Command("ffmpeg", "-y", "-framerate 60", "-i", "./output/img_glitched_%d.jpeg output.gif")
|
|
err = cmd.Run()
|
|
check(err, "cannot run ffmpeg command!")
|
|
//
|
|
}
|
|
|