Last active
May 7, 2025 13:22
-
-
Save robbiemu/bd41509aece4c94b2ce66eecc74e1d51 to your computer and use it in GitHub Desktop.
Waterways script - color variations
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
#!/usr/bin/env bash | |
# Generates 10-slot wallpapper solar JSONs from 6-stage image sets | |
set -euo pipefail | |
DIR="/Users/Shared/Wallpapers/WaterWays_Processed" | |
cd "$DIR" || { echo "bad path: $DIR"; exit 1; } | |
# 10-stage full-day solar path: altitude (°) and azimuth (°) | |
ALT=(60 40 20 5 -5 -15 -5 5 20 40) # noon to night and back | |
AZI=(180 135 90 60 30 0 330 300 270 225) # South → East → North → West arc | |
# Image indices to use for each slot (0-based into 6 images) | |
IMG_IDX=(0 1 2 3 4 5 4 3 2 1) # mirror usage | |
# Total entries | |
STAGE_COUNT=${#ALT[@]} | |
# Process all *_stage_1.jpg image sets | |
for img in *_stage_1.jpg; do | |
base=${img/_stage_1.jpg/} # e.g. Waterway1_Mac | |
json="${base}_wallpaper.json" # target JSON file | |
echo "• Generating ${json} (10-stage solar)" | |
tmp=$(mktemp) | |
{ | |
echo "[" | |
for ((i = 0; i < STAGE_COUNT; i++)); do | |
comma=$([[ $i -lt $((STAGE_COUNT - 1)) ]] && echo "," || echo "") | |
img_idx=${IMG_IDX[$i]} | |
# Construct file reference | |
filename="${base}_stage_$((img_idx + 1)).jpg" | |
altitude="${ALT[$i]}" | |
azimuth="${AZI[$i]}" | |
printf ' { "fileName": "%s", "altitude": %.2f, "azimuth": %.2f' \ | |
"$filename" "$altitude" "$azimuth" | |
# Add light/dark/primary flags | |
[[ $i == 0 ]] && printf ', "isPrimary": true, "isForLight": true' | |
[[ $i == 5 ]] && printf ', "isForDark": true' | |
printf ' }%s\n' "$comma" | |
done | |
echo "]" | |
} > "$tmp" | |
# Move if generated successfully | |
if [ -s "$tmp" ]; then | |
mv "$tmp" "$json" | |
echo "✓ $json written" | |
else | |
echo "Error: Failed to generate $json" | |
rm -f "$tmp" | |
exit 1 | |
fi | |
done |
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 | |
# Set input and output folders | |
INPUT_DIR="/Users/Shared/Wallpapers/WaterWays" | |
OUTPUT_DIR="/Users/Shared/Wallpapers/WaterWays_Processed" | |
mkdir -p "$OUTPUT_DIR" | |
# Requires: imagemagick, libheif (for heif-convert) | |
command -v magick >/dev/null || { echo "ImageMagick (magick) is required."; exit 1; } | |
command -v heif-convert >/dev/null || { echo "libheif's heif-convert is required."; exit 1; } | |
for heic in "$INPUT_DIR"/*.heic; do | |
base=$(basename "$heic" .heic) | |
temp_jpg="$OUTPUT_DIR/${base}_light.jpg" | |
echo "Extracting from: $heic" | |
heif-convert "$heic" "$temp_jpg" >/dev/null | |
echo "Generating stages for: $base" | |
for i in {1..6}; do | |
case $i in | |
1) b=1.00; s=1.00; t=0 ;; | |
2) b=0.80; s=0.90; t=5 ;; | |
3) b=0.65; s=0.75; t=7 ;; | |
4) b=0.50; s=0.60; t=10 ;; | |
5) b=0.40; s=0.50; t=12 ;; | |
6) b=0.38; s=0.50; t=20 ;; | |
esac | |
magick "$temp_jpg" \ | |
-modulate $(echo "$b*100" | bc),$(echo "$s*100" | bc),100 \ | |
-fill "rgb($t%,$t%,$((t+5))%)" -colorize $t \ | |
"$OUTPUT_DIR/${base}_stage_$i.jpg" | |
done | |
done | |
echo "All done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment