Last active
June 19, 2025 02:55
-
-
Save hermanho/c0f2ef2bf55237cc3e0f5cdb33ad9e73 to your computer and use it in GitHub Desktop.
Generate random images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
WIDTH=1500 | |
HEIGHT=1000 | |
MAX_JOBS=8 | |
# Kill all child processes if user presses Ctrl+C | |
trap "echo '❌ Interrupted. Cleaning up...'; kill 0; exit 1" SIGINT | |
generate_image() { | |
i=$1 | |
TEXT="photo ${i}" | |
OUTPUT="photo_${i}.heic" | |
echo "Generating $OUTPUT..." | |
dd if=/dev/urandom bs=3 count=$((WIDTH * HEIGHT)) status=none | \ | |
magick -size ${WIDTH}x${HEIGHT} -depth 8 rgb:- \ | |
-gravity center -pointsize 200 -fill white -annotate +0+0 "$TEXT" \ | |
-define heic:compression=hevc -quality 80 "$OUTPUT" | |
} | |
job_count=0 | |
for i in $(seq -w 1 500); do | |
generate_image "$i" & | |
((++job_count >= MAX_JOBS)) && wait && job_count=0 | |
done | |
wait | |
echo "✅ Done generating 500 HEIC files with quality 80." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
WIDTH=800 | |
HEIGHT=1200 | |
MAX_JOBS=8 | |
# Kill all child processes if user presses Ctrl+C | |
trap "echo '❌ Interrupted. Cleaning up...'; kill 0; exit 1" SIGINT | |
generate_image() { | |
i=$1 | |
i=$(expr 500 + $i) | |
TEXT="photo ${i}" | |
OUTPUT="photo_${i}.heic" | |
echo "Generating $OUTPUT..." | |
dd if=/dev/urandom bs=3 count=$((WIDTH * HEIGHT)) status=none | \ | |
magick -size ${WIDTH}x${HEIGHT} -depth 8 rgb:- \ | |
-gravity center -pointsize 150 -fill white -annotate +0+0 "$TEXT" \ | |
-define heic:compression=hevc -quality 80 "$OUTPUT" | |
} | |
job_count=0 | |
for i in $(seq -w 1 500); do | |
generate_image "$i" & | |
((++job_count >= MAX_JOBS)) && wait && job_count=0 | |
done | |
wait | |
echo "✅ Done generating 500 HEIC files with quality 80." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MAX_JOBS=12 | |
# Kill all child processes if user presses Ctrl+C | |
trap "echo '❌ Interrupted. Cleaning up...'; kill 0; exit 1" SIGINT | |
generate_image() { | |
i=$1 | |
TEXT="photo ${i}" | |
OUTPUT="photo_${i}.jpg" | |
echo "Generating $OUTPUT..." | |
dd if=/dev/urandom bs=3 count=$((750 * 500)) status=none | \ | |
magick -size 750x500 -depth 8 rgb:- \ | |
-filter point -resize 1500x1000 \ | |
-gravity center -pointsize 200 -fill white -annotate +0+0 "$TEXT" \ | |
-quality 100 "$OUTPUT" | |
} | |
job_count=0 | |
for i in $(seq -w 1 500); do | |
generate_image "$i" & | |
((++job_count >= MAX_JOBS)) && wait && job_count=0 | |
done | |
wait | |
echo "✅ Done generating 500 JPG files." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MAX_JOBS=12 | |
# Kill all child processes if user presses Ctrl+C | |
trap "echo '❌ Interrupted. Cleaning up...'; kill 0; exit 1" SIGINT | |
generate_image() { | |
i=$1 | |
i=$(expr 500 + $i) | |
TEXT="photo ${i}" | |
OUTPUT="photo_${i}.jpg" | |
echo "Generating $OUTPUT..." | |
dd if=/dev/urandom bs=3 count=$((750 * 500)) status=none | \ | |
magick -size 750x500 -depth 8 rgb:- \ | |
-filter point -resize 1500x1000 \ | |
-gravity center -pointsize 200 -fill white -annotate +0+0 "$TEXT" \ | |
-quality 100 "$OUTPUT" | |
} | |
job_count=0 | |
for i in $(seq -w 1 500); do | |
generate_image "$i" & | |
((++job_count >= MAX_JOBS)) && wait && job_count=0 | |
done | |
wait | |
echo "✅ Done generating 500 JPG files." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment