now can add chance to glitch
This commit is contained in:
parent
2f3c65ae9f
commit
23585f58a8
@ -71,12 +71,11 @@ func copyImage(inputFile string, outputFile string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateGlitchedSequence(inputFile string, totalImages int, shitSize int64, iterations int64) {
|
func generateGlitchedSequence(inputFile string, totalImages int, shitSize int64, iterations int64, chanceToRandom int32) {
|
||||||
for i := 1; i <= totalImages; i++ {
|
for i := 1; i <= totalImages; i++ {
|
||||||
outputFileName := fmt.Sprintf("img_glitched_%d.jpeg", i) // Generate unique filenames
|
outputFileName := fmt.Sprintf("img_glitched_%d.jpeg", i) // Generate unique filenames
|
||||||
|
|
||||||
// Randomly decide whether to glitch or copy the image
|
if rand.Int32N(100) < chanceToRandom {
|
||||||
if rand.Int32N(2) == 0 {
|
|
||||||
// Glitched image
|
// Glitched image
|
||||||
err := glitchImage(inputFile, outputFileName, shitSize, iterations)
|
err := glitchImage(inputFile, outputFileName, shitSize, iterations)
|
||||||
check(err, "failed to glitch image: %w")
|
check(err, "failed to glitch image: %w")
|
||||||
|
18
main.go
18
main.go
@ -15,12 +15,13 @@ import (
|
|||||||
const MAX_SIZE = 1000000
|
const MAX_SIZE = 1000000
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) < 5 {
|
if len(os.Args) < 6 {
|
||||||
fmt.Println("Usage: go run main.go <source-file> <number-of-copies> <shit-size> <iterations>")
|
fmt.Println("Usage: go run main.go <source-file> <number-of-copies> <shit-size> <iterations> <chance-to-random % (0-100)>")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceFile := os.Args[1]
|
sourceFile := os.Args[1]
|
||||||
|
|
||||||
numCopies, err := strconv.Atoi(os.Args[2])
|
numCopies, err := strconv.Atoi(os.Args[2])
|
||||||
if err != nil || numCopies <= 0 {
|
if err != nil || numCopies <= 0 {
|
||||||
fmt.Println("Invalid number of copies. Must be a positive integer.")
|
fmt.Println("Invalid number of copies. Must be a positive integer.")
|
||||||
@ -39,8 +40,19 @@ func main() {
|
|||||||
iterations, err := strconv.ParseInt(os.Args[4], 10, 8)
|
iterations, err := strconv.ParseInt(os.Args[4], 10, 8)
|
||||||
check(err, "Cannot parse iterations. Must be a positive integer")
|
check(err, "Cannot parse iterations. Must be a positive integer")
|
||||||
|
|
||||||
|
chanceToRandom, err := strconv.ParseInt(os.Args[5], 10, 32)
|
||||||
|
if err != nil || chanceToRandom < 0 {
|
||||||
|
fmt.Println("Invalid random chance value. Must be a positive integer (0-100).")
|
||||||
|
return
|
||||||
|
} else if chanceToRandom > 100 {
|
||||||
|
fmt.Println("Invalid random chance value. Must range between 0 to 100.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(os.Stdout, "Generating:\n %d copies of %s\n %d random bytes of data\n %d interations(s)\n Chance to random %d%%\n\n",
|
||||||
|
numCopies, sourceFile, shitSize, iterations, chanceToRandom)
|
||||||
makeOutputDir()
|
makeOutputDir()
|
||||||
generateGlitchedSequence(sourceFile, numCopies, shitSize, iterations)
|
generateGlitchedSequence(sourceFile, numCopies, shitSize, iterations, int32(chanceToRandom))
|
||||||
ffmpegGenerateMP4()
|
ffmpegGenerateMP4()
|
||||||
clearOutputDir()
|
clearOutputDir()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user