TXT-Graphics-Converter

Random Typography Project: jeder einzelne Charakter wird in eine zufällig ausgesuchte Schrift konvertiert. Da Schrift-Daten nicht nur Buchstaben, sondern auch Grafiken enthalten können, ergibt sich eine typographische Collage mit den entsprechenden Schriften, deren Parameter (size, kerning, leading) alle geändert werden können. Alle Fonts von dafont.com



#!/bin/bash
# Random Font Typography Script
# Each character from the text file is rendered with a random font from the list below

OFILE="$RANDOM"

# --- Input / Output (Hardwired) ---
INPUT="./input.txt"
OUTPUT="./$OFILE.png"

# --- Fonts (Full Paths) ---
FONTS=(
  "./fonts/EmojiFont.ttf"
  "./fonts/LEDLIGHT.otf"
  "./fonts/Logos tfb.ttf"
  "./fonts/BluetagBoldItalic_PERSONAL_USE_ONLY.otf"
  "./fonts/Positive System.otf"
  "./fonts/ArabTVlogos.ttf"
  "./fonts/clothing logos.ttf"
  "./fonts/Sci-Fi-Logos.ttf"
  "./fonts/the world-'s best logos.ttf"
  "./fonts/WarnerLogoFontNine.TTF"
  "./fonts/code128.ttf"
  "./fonts/Eau de rose.ttf"
  "./fonts/Grunge Strokes 01.ttf"
  "./fonts/Logos I love.ttf"
  "./fonts/openlogos.ttf"
  "./fonts/THEBOMB.TTF"
  "./fonts/WC_Rhesus_B_Bta.ttf"
  "./fonts/Dripping.ttf"
  "./fonts/meeksa.ttf"
  "./fonts/RFX Splatz.ttf"
  "./fonts/Sneakers.ttf"
  "./fonts/splatter.ttf"
)

# --- Config ---
FONT_SIZE=80
BG_COLOR="black"
TEXT_COLOR="white"
KERNING=-8
LEADING=-25
CHARS_PER_LINE=12
TMPDIR=$(mktemp -d)

# --- Read text file ---
if [[ ! -f "$INPUT" ]]; then
  echo "❌ Text file not found: $INPUT"
  exit 1
fi
TEXT=$(cat "$INPUT" | tr -d '\r')

# --- Split text into lines ---
LINES=()
while IFS= read -r LINE; do
  while [[ -n "$LINE" ]]; do
    LINES+=("${LINE:0:$CHARS_PER_LINE}")
    LINE="${LINE:$CHARS_PER_LINE}"
  done
done <<< "$TEXT"

# --- Function: render a single line ---
render_line() {
  local LINE="$1"
  local OUTFILE="$2"
  local x_offset=0
  local TMP_CANVAS="$TMPDIR/canvas.miff"

  magick -size 2000x2000 xc:none "$TMP_CANVAS"

  for (( c=0; c<${#LINE}; c++ )); do
    CHAR="${LINE:$c:1}"

    # Handle spaces and special characters safely
    if [[ "$CHAR" == " " ]]; then
      CHAR=" "   # just skip drawing empty glyph
    fi
    SAFE_CHAR=$(printf '%s' "$CHAR" | sed "s/'/\\\\'/g; s/\"/\\\\\"/g")

    FONT="${FONTS[$((RANDOM % ${#FONTS[@]}))]}"

    # Only try to render printable characters
    if [[ "$CHAR" =~ [[:print:]] ]]; then
      magick -background none -fill "$TEXT_COLOR" \
              -font "$FONT" -pointsize "$FONT_SIZE" \
              label:"$SAFE_CHAR" "$TMPDIR/char_$c.png" 2>/dev/null || continue
      composite -geometry +$x_offset+0 "$TMPDIR/char_$c.png" "$TMP_CANVAS" "$TMP_CANVAS"
    fi

    x_offset=$((x_offset + FONT_SIZE + KERNING))
  done

  mv "$TMP_CANVAS" "$OUTFILE"
}

# --- Render all lines ---
line_y=0
magick -size 1000x1000 xc:"$BG_COLOR" "$TMPDIR/final.miff"

for (( i=0; i<${#LINES[@]}; i++ )); do
  render_line "${LINES[$i]}" "$TMPDIR/line_$i.miff"
  composite -geometry +0+$line_y "$TMPDIR/line_$i.miff" "$TMPDIR/final.miff" "$TMPDIR/final.miff"
  line_y=$((line_y + FONT_SIZE + LEADING))
done

# --- Output ---
magick "$TMPDIR/final.miff" "$OUTPUT"
rm -rf "$TMPDIR"

echo "✅ Done! Created overlapping typography at: $OUTPUT"

Automatically create moodboards

Moodboards, aber automatisch. Collage-Erstellung mit imagemagick. Aussehen ist abhängig von den Quelldaten, so, es kann auch ein messy Familienalbum sein, oder ein RSS-Nachrichtensystem, its up to you.



1760814789.jpg

1760813686.jpg


1760813230.jpg


#!/bin/bash
# Create a colorful random moodboard with reduced overlap (ImageMagick v7)
# Output files are timestamped and stored in ./moodboards/

SRC_DIR="/home/pi/imagefolder"
OUT_DIR="/home/pi/moodboards"
mkdir -p "$OUT_DIR"

WIDTH=1280
HEIGHT=720
MAX_IMAGES=8

# Timestamped output filename
TIMESTAMP=$(date +%s)
OUT_FILE="${OUT_DIR}/moodboard_${TIMESTAMP}.jpg"

TMP_DIR=$(mktemp -d)

# Pick random JPEG images
mapfile -t FILES < <(find "$SRC_DIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) | shuf -n $MAX_IMAGES)

# Create RGB white canvas
magick -size ${WIDTH}x${HEIGHT} canvas:white -colorspace sRGB "$TMP_DIR/base.png"

# Determine layout grid positions (2x4 grid for up to 8 images)
COLS=4
ROWS=2
CELL_W=$((WIDTH / COLS))
CELL_H=$((HEIGHT / ROWS))

i=0
for f in "${FILES[@]}"; do
  ((i++))

  # Resize proportionally to fit in a cell
  magick "$f" -colorspace sRGB -resize "${CELL_W}x${CELL_H}>" "$TMP_DIR/img_${i}.png"

  # Random small rotation (-10 to +10)
  ANGLE=$((RANDOM % 21 - 10))
  magick "$TMP_DIR/img_${i}.png" -background none -rotate "$ANGLE" "$TMP_DIR/rot_${i}.png"

  # Grid position with a *wider* random offset (±80 px for more overlap)
  row=$(( (i-1) / COLS ))
  col=$(( (i-1) % COLS ))
  XPOS=$(( col * CELL_W + RANDOM % 161 - 80 ))
  YPOS=$(( row * CELL_H + RANDOM % 161 - 80 ))

  # Composite with minimal overlap
  magick "$TMP_DIR/base.png" "$TMP_DIR/rot_${i}.png" \
        -colorspace sRGB -geometry +${XPOS}+${YPOS} -compose over -composite "$TMP_DIR/base.png"
done

# Save final moodboard
magick "$TMP_DIR/base.png" -colorspace sRGB "$OUT_FILE"

rm -rf "$TMP_DIR"
echo "✅ Moodboard created: $OUT_FILE"