feat(wallpapers): automate element spectrum download and panorama generation

Add script for downloading and processing element emission spectra
from Wikimedia Commons.

- Read element definitions from get_images.txt
- Retrieve original spectrum images from Wikimedia Commons
- Download element spectrum PNG files automatically
- Generate standardized filenames using atomic metadata
- Resize images to 3840px width
- Crop images to 3840x540 panorama format
- Export processed files to wallpaper collection directory
- Report missing spectrum images
- Automate creation of element-themed desktop wallpapers
This commit is contained in:
Lucas Vivohost committed 2026-09-14 12:43:38 +02:00
1 parent 16c69ac7df
commit fbcbf008ea
3 files changed
+102 -16

No files matched your search

+102
View File
@@ -0,0 +1,102 @@
#!/bin/bash
###############################################################################
# Script Name: get_element_spectra.sh
#
# Description:
# Downloads visible-light emission spectrum images for chemical elements
# from Wikimedia Commons and converts them into panorama wallpapers.
#
# For each entry in get_images.txt, the script:
# 1. Reads element information from the input file.
# 2. Builds a standardized output filename.
# 3. Locates the corresponding spectrum image on Wikimedia Commons.
# 4. Downloads the original PNG file.
# 5. Renames the image using element metadata.
# 6. Resizes the image to 3840 pixels wide.
# 7. Crops the image to 3840x540 pixels.
# 8. Moves the finished panorama wallpaper to the destination folder.
#
# Input Format (get_images.txt):
# element_name atomic_number symbol
#
# Example:
# hydrogen 001 H
# helium 002 He
# lithium 003 Li
#
# Output Example:
# Elements_Panorama_001_H_Hydrogen.png
#
# Requirements:
# - Bash
# - wget
# - ImageMagick (convert)
# - Internet connection
#
# Usage:
# chmod +x get_element_spectra.sh
# ./get_element_spectra.sh
#
# Notes:
# - The script expects get_images.txt in the current directory.
# - Images are downloaded from Wikimedia Commons.
# - Missing images are reported and skipped.
#
###############################################################################
while IFS= read -r line; do
# Build output filename:
# <atomic_number>_<symbol>_<Element>.png
element_name="$(
printf "%s_%s_%s%s\n" \
"$(echo "$line" | cut -f2 -d' ')" \
"$(echo "$line" | cut -f3 -d' ')" \
"$(echo "$line" | cut -f1 -d' ' | head -c 1 | tr 'a-z' 'A-Z')" \
"$(echo "$line" | cut -f1 -d' ' | tail -c +2)"
)"
# Build capitalized element name used by Wikimedia
element="$(
printf "%s%s\n" \
"$(echo "$line" | cut -f1 -d' ' | head -c 1 | tr 'a-z' 'A-Z')" \
"$(echo "$line" | cut -f1 -d' ' | tail -c +2)"
)"
# Retrieve original image URL from Wikimedia Commons
LINK="$(
wget -qO- "https://commons.wikimedia.org/wiki/File:${element}_spectrum_visible.png" \
| grep "Original file" \
| grep -o 'href="[^"]*' \
| tail -c +7
)"
if [ -z "$LINK" ]; then
echo "No spectrum image found for ${element}"
continue
else
echo "Downloading ${element}: ${LINK}"
fi
# Download original image
wget "$LINK"
# Rename downloaded image
mv "${element}_spectrum_visible.png" "${element_name}.png"
# Resize image to 3840 pixels wide
convert "${element_name}.png" \
-resize 3840x \
"${element_name}.png"
# Crop to panorama format
convert "${element_name}.png" \
-crop 3840x540+0+0 \
"${element_name}.png"
# Move final image to wallpaper directory
mv "${element_name}.png" \
"/home/lucas/Documents/Dokumente/Zeug/Wallpaper/Desktop1920x1080/Elements/Elements_Panorama_${element_name}.png"
done < "get_images.txt"
File renamed without changes.
-16
View File
@@ -1,16 +0,0 @@
#!/bin/bash
while IFS= read -r line; do
element_name="$(printf "%s_%s_%s%s\n" "$(echo $line | cut -f2 -d' ')" "$(echo $line | cut -f3 -d' ')" "$(echo $line | cut -f1 -d' ' | head -c 1 | tr 'a-z' 'A-Z')" "$(echo $line | cut -f1 -d' ' | tail -c +2)")"
element="$(printf "%s%s\n" "$(echo $line | cut -f1 -d' ' | head -c 1 | tr 'a-z' 'A-Z')" "$(echo $line | cut -f1 -d' ' | tail -c +2)")"
LINK="$(wget -qO- https://commons.wikimedia.org/wiki/File:${element}_spectrum_visible.png | grep "Original file" | grep -o 'href="[^"]*' | tail -c +7)"
if [ "$LINK" == "" ]; then
echo "None for $element"
else
echo $LINK
fi
wget $LINK
mv ${element}_spectrum_visible.png ${element_name}.png
convert ${element_name}.png -resize 3840x ${element_name}.png
convert ${element_name}.png -crop 3840x540+0+0 ${element_name}.png
mv ${element_name}.png /home/lucas/Documents/Dokumente/Zeug/Wallpaper/Desktop1920x1080/Elements/Elements_Panorama_${element_name}.png
done < "get_images.txt"