Skip to content

Instantly share code, notes, and snippets.

@hermanho
Last active August 15, 2025 23:32
Show Gist options
  • Save hermanho/c0f2ef2bf55237cc3e0f5cdb33ad9e73 to your computer and use it in GitHub Desktop.
Save hermanho/c0f2ef2bf55237cc3e0f5cdb33ad9e73 to your computer and use it in GitHub Desktop.
Generate random images
#!/bin/bash
WIDTH=4032
HEIGHT=3024
MAX_JOBS=4
# Kill all child processes if user presses Ctrl+C
trap "echo '❌ Interrupted. Cleaning up...'; kill 0; exit 1" SIGINT
generate_image() {
i=$1
i=$(printf %03d $i)
TEXT="photo ${i} heic"
OUTPUT="photo_${i}.heic"
echo "Generating $OUTPUT..."
dd if=/dev/urandom bs=5 count=$((300 * 225)) status=none | \
magick -size 300x225 -depth 10 rgba:- \
-filter point -resize ${WIDTH}x${HEIGHT} \
-gravity center -pointsize 400 -fill white -annotate +0+0 "$TEXT" \
-alpha off \
-define heic:compression=hevc -quality 85 "$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 85."
#!/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=$(printf %03d $(expr 500 + $i))
TEXT="photo ${i} heic"
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" \
-alpha off \
-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."
#!/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=$(printf %03d $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" \
-alpha off \
-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."
#!/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=$(printf %03d $(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" \
-alpha off \
-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