move move old scripts
This commit is contained in:
1 parent
93b262977b
commit
208fbd96b4
27 files changed
+346
No files matched your search
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Directory to start from (default is current directory if none given)
|
||||
DIR="${1:-.}"
|
||||
|
||||
# Optional prefix filter (second argument)
|
||||
PREFIX="${2:-}"
|
||||
|
||||
# JPEG/WEBP compression quality (1–100, lower = more compression)
|
||||
QUALITY=85
|
||||
|
||||
# Target max size
|
||||
MAXSIZE="1920x1040"
|
||||
|
||||
# Recursively find images and compress them
|
||||
find "$DIR" -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' \) | while read -r FILE; do
|
||||
BASENAME=$(basename "$FILE")
|
||||
EXT="${FILE##*.}"
|
||||
EXT_LOWER=$(echo "$EXT" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
# Skip if prefix is set and filename doesn’t start with it
|
||||
if [ -n "$PREFIX" ] && [[ "$BASENAME" != "$PREFIX"* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Processing: $FILE"
|
||||
|
||||
TMPFILE="$(mktemp --suffix=".$EXT_LOWER")"
|
||||
|
||||
case "$EXT_LOWER" in
|
||||
jpg|jpeg)
|
||||
convert "$FILE" -resize "$MAXSIZE"\> -strip -interlace Plane -quality $QUALITY "$TMPFILE"
|
||||
;;
|
||||
png|webp)
|
||||
convert "$FILE" -resize "$MAXSIZE"\> -strip -quality $QUALITY "$TMPFILE"
|
||||
;;
|
||||
esac
|
||||
|
||||
mv "$TMPFILE" "$FILE"
|
||||
done
|
||||
|
||||
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
|
||||
###############################################################################
|
||||
# Script Name: crop_images.sh
|
||||
#
|
||||
# Description:
|
||||
# Safely processes JPEG images in the current directory. If an image has a
|
||||
# width of 3546 pixels, the script:
|
||||
# 1. Creates a cropped copy (2448x3264 from the top-left corner).
|
||||
# 2. Saves the cropped image as *_c.jpg.
|
||||
# 3. Renames the original image as *_u.jpg.
|
||||
#
|
||||
# Features:
|
||||
# - Processes only .jpg files.
|
||||
# - Handles filenames containing spaces.
|
||||
# - Verifies that ImageMagick is installed.
|
||||
# - Skips files that have already been processed.
|
||||
# - Uses ImageMagick's format output instead of parsing command output.
|
||||
#
|
||||
# Requirements:
|
||||
# - Bash
|
||||
# - ImageMagick (identify, convert)
|
||||
#
|
||||
# Usage:
|
||||
# chmod +x crop_images.sh
|
||||
# ./crop_images.sh
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Verify required commands exist
|
||||
for cmd in identify convert; do
|
||||
command -v "$cmd" >/dev/null 2>&1 || {
|
||||
echo "Error: '$cmd' command not found. Install ImageMagick."
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
# Process JPEG files only
|
||||
for img in *.jpg *.JPG; do
|
||||
|
||||
# Skip if no matching files exist
|
||||
[[ -f "$img" ]] || continue
|
||||
|
||||
# Skip files already processed
|
||||
[[ "$img" =~ _c\.jpg$|_u\.jpg$ ]] && continue
|
||||
|
||||
# Get image dimensions (e.g. 3546x4728)
|
||||
size=$(identify -format "%wx%h" "$img" 2>/dev/null) || {
|
||||
echo "Skipping invalid image: $img"
|
||||
continue
|
||||
}
|
||||
|
||||
# Process only images whose width is exactly 3546 pixels
|
||||
if [[ "$size" == 3546x* ]]; then
|
||||
|
||||
echo "Processing: $img ($size)"
|
||||
|
||||
cropped="${img%.jpg}_c.jpg"
|
||||
original="${img%.jpg}_u.jpg"
|
||||
|
||||
# Handle uppercase extension
|
||||
if [[ "$img" == *.JPG ]]; then
|
||||
cropped="${img%.JPG}_c.jpg"
|
||||
original="${img%.JPG}_u.jpg"
|
||||
fi
|
||||
|
||||
# Create cropped image
|
||||
convert "$img" -crop 2448x3264+0+0 "$cropped"
|
||||
|
||||
# Rename original image
|
||||
mv "$img" "$original"
|
||||
|
||||
echo " Created: $cropped"
|
||||
echo " Renamed: $original"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
echo "Done."
|
||||
+102
@@ -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"
|
||||
Executable
+105
@@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
###############################################################################
|
||||
# Script Name: find_panoramas.sh
|
||||
#
|
||||
# Description:
|
||||
# Recursively scans a directory for JPG and PNG images and identifies
|
||||
# potential panorama images using multiple detection methods:
|
||||
#
|
||||
# 1. Aspect ratio < 0.5
|
||||
# 2. Aspect ratio > 1.8
|
||||
# 3. Width > 3 × Height
|
||||
#
|
||||
# Images already tagged as "Panorama" are ignored.
|
||||
#
|
||||
# Matching images are:
|
||||
# - Logged to a timestamped logfile
|
||||
# - Optionally copied to a review directory
|
||||
#
|
||||
# Requirements:
|
||||
# - Bash
|
||||
# - ImageMagick (identify)
|
||||
# - bc
|
||||
#
|
||||
# Usage:
|
||||
# ./find_panoramas.sh
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
IMG_DIR="/home/lucas/Pictures"
|
||||
COPY_DIR="/home/lucas/Downloads"
|
||||
|
||||
PANORAMA_AR_LT="0.5"
|
||||
PANORAMA_AR_HT="1.8"
|
||||
|
||||
DATE=$(date +"%Y%m%d_%H%M%S")
|
||||
LOGFILE="${IMG_DIR}/panorama_${DATE}.log"
|
||||
|
||||
touch "$LOGFILE"
|
||||
|
||||
write_log() {
|
||||
echo "$@"
|
||||
echo "$@" >> "$LOGFILE"
|
||||
}
|
||||
|
||||
# Verify dependencies
|
||||
for cmd in identify bc; do
|
||||
command -v "$cmd" >/dev/null 2>&1 || {
|
||||
echo "Error: '$cmd' not found"
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
find "$IMG_DIR" \
|
||||
\( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) \
|
||||
-print0 |
|
||||
while IFS= read -r -d '' img; do
|
||||
|
||||
# Get dimensions
|
||||
dimensions=$(identify -format "%wx%h" "$img" 2>/dev/null) || {
|
||||
write_log "Skipping invalid image: $img"
|
||||
continue
|
||||
}
|
||||
|
||||
width=${dimensions%x*}
|
||||
height=${dimensions#*x}
|
||||
|
||||
# Avoid divide-by-zero
|
||||
[[ "$height" -eq 0 ]] && continue
|
||||
|
||||
# Calculate aspect ratio
|
||||
aspect_ratio=$(echo "scale=4; $height / $width" | bc -l)
|
||||
|
||||
# Skip images already marked Panorama
|
||||
if identify -verbose "$img" 2>/dev/null | grep -q "Panorama"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
panorama=false
|
||||
|
||||
# Aspect-ratio checks
|
||||
if (( $(echo "$aspect_ratio < $PANORAMA_AR_LT" | bc -l) )); then
|
||||
panorama=true
|
||||
elif (( $(echo "$aspect_ratio > $PANORAMA_AR_HT" | bc -l) )); then
|
||||
panorama=true
|
||||
fi
|
||||
|
||||
# Width > 3 × Height check
|
||||
if (( width > height * 3 )); then
|
||||
panorama=true
|
||||
fi
|
||||
|
||||
if [[ "$panorama" == true ]]; then
|
||||
|
||||
write_log "PANORAMA | ${dimensions} | AR=${aspect_ratio} | ${img}"
|
||||
|
||||
# Copy for manual review
|
||||
cp -n "$img" "$COPY_DIR/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
write_log "Scan complete."
|
||||
Executable
+141
@@ -0,0 +1,141 @@
|
||||
#!/bin/bash
|
||||
|
||||
###############################################################################
|
||||
# Script Name: collect-wallpapers.sh
|
||||
#
|
||||
# Description:
|
||||
# Scans a directory tree for image files and prepares them for wallpaper use.
|
||||
#
|
||||
# The script:
|
||||
# 1. Searches recursively for JPG, JPEG, and PNG images.
|
||||
# 2. Renames files by replacing spaces with underscores.
|
||||
# 3. Converts JPG/JPEG images to PNG format.
|
||||
# 4. Calculates image aspect ratio and width.
|
||||
# 5. Identifies images matching a target screen aspect ratio.
|
||||
# 6. Optionally copies matching images to a wallpaper collection folder.
|
||||
#
|
||||
# Matching Criteria:
|
||||
# - Aspect ratio close to 16:9 portrait (0.5625)
|
||||
# - Configurable tolerance range
|
||||
# - Minimum image width requirement
|
||||
#
|
||||
# Requirements:
|
||||
# - Bash
|
||||
# - ImageMagick (identify, convert)
|
||||
# - bc
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# Scan only:
|
||||
# ./collect-wallpapers.sh <image_directory>
|
||||
#
|
||||
# Scan and copy matching images:
|
||||
# ./collect-wallpapers.sh <image_directory> -m
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# Analyze images:
|
||||
# ./collect-wallpapers.sh ~/Pictures
|
||||
#
|
||||
# Collect wallpaper candidates:
|
||||
# ./collect-wallpapers.sh ~/Pictures -m
|
||||
#
|
||||
# Output:
|
||||
# Matching files are copied to:
|
||||
#
|
||||
# /data/Ubuntu_Data/Videos/.stuff/
|
||||
#
|
||||
# Notes:
|
||||
# - JPG/JPEG files are converted to PNG.
|
||||
# - Spaces in filenames are replaced with underscores.
|
||||
# - Original PNG files remain unchanged.
|
||||
# - Original JPG/JPEG files are removed after conversion.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <image_directory> [-m]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMG_PATH="$1"
|
||||
|
||||
MOVE=false
|
||||
if [ "$2" == "-m" ]; then
|
||||
MOVE=true
|
||||
fi
|
||||
|
||||
echo "Path: $IMG_PATH"
|
||||
|
||||
find "$IMG_PATH" \( -name "*.png" -o -name "*.jp*g" \)
|
||||
|
||||
files="$(find "$IMG_PATH" \( -name "*.png" -o -name "*.jp*g" \) | wc -l)"
|
||||
|
||||
printf "%s Files, Move: %s\n" "$files" "$MOVE"
|
||||
|
||||
read -n 1 -s -r -p "Press any key to continue"
|
||||
printf "\n"
|
||||
|
||||
minImgX="1400"
|
||||
screenAR="0.5625"
|
||||
AR_tolerance="0.2"
|
||||
|
||||
counter=0
|
||||
|
||||
find "$IMG_PATH" \( -name "*.png" -o -name "*.jp*g" \) | while read -r img; do
|
||||
|
||||
((counter++))
|
||||
|
||||
object_path="$(dirname "$img")/"
|
||||
img="$(basename "$img")"
|
||||
|
||||
# Replace spaces with underscores
|
||||
if [[ "$img" == *" "* ]]; then
|
||||
new_img="$(echo "$img" | sed 's/ \+/_/g')"
|
||||
|
||||
mv "${object_path}${img}" "${object_path}${new_img}"
|
||||
|
||||
img="$new_img"
|
||||
fi
|
||||
|
||||
# Convert JPG/JPEG to PNG
|
||||
if echo "$img" | grep -qiE '\.jpe?g$'; then
|
||||
|
||||
convert "${object_path}${img}" \
|
||||
"${object_path}$(echo "$img" | sed 's/\.[jJ][pP][eE]\?[gG]$/.png/')"
|
||||
|
||||
rm "${object_path}${img}"
|
||||
|
||||
img="$(echo "$img" | sed 's/\.[jJ][pP][eE]\?[gG]$/.png/')"
|
||||
fi
|
||||
|
||||
# Get image dimensions
|
||||
dimensions="$(identify -format "%wx%h" "${object_path}${img}" 2>/dev/null)"
|
||||
|
||||
width="${dimensions%x*}"
|
||||
height="${dimensions#*x}"
|
||||
|
||||
if [[ -z "$width" || -z "$height" || "$height" -eq 0 ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Calculate aspect ratio (height / width)
|
||||
imageAR="$(echo "scale=6; $height / $width" | bc -l)"
|
||||
|
||||
# Match wallpaper criteria
|
||||
if [[ "$MOVE" == true \
|
||||
&& $(echo "$imageAR < $screenAR*(1+$AR_tolerance)" | bc -l) -eq 1 \
|
||||
&& $(echo "$imageAR > $screenAR*(1-$AR_tolerance)" | bc -l) -eq 1 \
|
||||
&& $(echo "$width > $minImgX" | bc -l) -eq 1 ]]; then
|
||||
|
||||
printf "%d/%s: %s\t%s\n" \
|
||||
"$counter" \
|
||||
"$files" \
|
||||
"$img" \
|
||||
"$imageAR"
|
||||
|
||||
cp "${object_path}${img}" \
|
||||
"/data/Ubuntu_Data/Videos/.stuff/"
|
||||
fi
|
||||
|
||||
done
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
hydrogen 1 H Hydrogen spectrum visible.png
|
||||
helium 2 He Helium spectrum visible.png
|
||||
lithium 3 Li Lithium spectrum visible.png
|
||||
beryllium 4 Be Beryllium spectrum visible.png
|
||||
boron 5 B Boron spectrum visible.png
|
||||
carbon 6 C Carbon spectrum visible.png
|
||||
nitrogen 7 N Nitrogen spectrum visible.png
|
||||
oxygen 8 O Oxygen spectrum visible.png
|
||||
fluorine 9 F Fluorine spectrum visible.png
|
||||
neon 10 Ne Neon spectrum visible.png
|
||||
sodium 11 Na Sodium spectrum visible.png
|
||||
magnesium 12 Mg Magnesium spectrum visible.png
|
||||
aluminium 13 Al Aluminium spectrum visible.png
|
||||
silicon 14 Si Silicon spectrum visible.png
|
||||
phosphorus 15 P Phosphorus spectrum visible.png
|
||||
sulfur 16 S Sulfur spectrum visible.png
|
||||
chlorine 17 Cl Chlorine spectrum visible.png
|
||||
argon 18 Ar Argon spectrum visible.png
|
||||
potassium 19 K Potassium spectrum visible.png
|
||||
calcium 20 Ca Calcium spectrum visible.png
|
||||
scandium 21 Sc Scandium spectrum visible.png
|
||||
titanium 22 Ti Titanium spectrum visible.png
|
||||
vanadium 23 V Vanadium spectrum visible.png
|
||||
chromium 24 Cr Chromium spectrum visible.png
|
||||
manganese 25 Mn Manganese spectrum visible.png
|
||||
iron 26 Fe Iron spectrum visible.png
|
||||
cobalt 27 Co Cobalt spectrum visible.png
|
||||
nickel 28 Ni Nickel spectrum visible.png
|
||||
copper 29 Cu Copper spectrum visible.png
|
||||
zinc 30 Zn Zinc spectrum visible.png
|
||||
gallium 31 Ga Gallium spectrum visible.png
|
||||
germanium 32 Ge Germanium spectrum visible.png
|
||||
arsenic 33 As Arsenic spectrum visible.png
|
||||
selenium 34 Se Selenium spectrum visible.png
|
||||
bromine 35 Br Bromine spectrum visible.png
|
||||
krypton 36 Kr Krypton spectrum visible.png
|
||||
rubidium 37 Rb Rubidium spectrum visible.png
|
||||
strontium 38 Sr Strontium spectrum visible.png
|
||||
yttrium 39 Y Yttrium spectrum visible.png
|
||||
zirconium 40 Zr Zirconium spectrum visible.png
|
||||
niobium 41 Nb Niobium spectrum visible.png
|
||||
molybdenum 42 Mo Molybdenum spectrum visible.png
|
||||
technetium 43 Tc Technetium spectrum visible.png
|
||||
ruthenium 44 Ru Ruthenium spectrum visible.png
|
||||
rhodium 45 Rh Rhodium spectrum visible.png
|
||||
palladium 46 Pd Palladium spectrum visible.png
|
||||
silver 47 Ag Silver spectrum visible.png
|
||||
cadmium 48 Cd Cadmium spectrum visible.png
|
||||
indium 49 In Indium spectrum visible.png
|
||||
tin 50 Sn Tin spectrum visible.png
|
||||
antimony 51 Sb Antimony spectrum visible.png
|
||||
tellurium 52 Te Tellurium spectrum visible.png
|
||||
iodine 53 I Iodine spectrum visible.png
|
||||
xenon 54 Xe Xenon spectrum visible.png
|
||||
caesium 55 Cs Caesium spectrum visible.png
|
||||
barium 56 Ba Barium spectrum visible.png
|
||||
lanthanum 57 La Lanthanum spectrum visible.png
|
||||
cerium 58 Ce Cerium spectrum visible.png
|
||||
praseodymium 59 Pr Praseodymium spectrum visible.png
|
||||
neodymium 60 Nd Neodymium spectrum visible.png
|
||||
promethium 61 Pm Promethium spectrum visible.png
|
||||
samarium 62 Sm Samarium spectrum visible.png
|
||||
europium 63 Eu Europium spectrum visible.png
|
||||
gadolinium 64 Gd Gadolinium spectrum visible.png
|
||||
terbium 65 Tb Terbium spectrum visible.png
|
||||
dysprosium 66 Dy Dysprosium spectrum visible.png
|
||||
holmium 67 Ho Holmium spectrum visible.png
|
||||
erbium 68 Er Erbium spectrum visible.png
|
||||
thulium 69 Tm Thulium spectrum visible.png
|
||||
ytterbium 70 Yb Ytterbium spectrum visible.png
|
||||
lutetium 71 Lu Lutetium spectrum visible.png
|
||||
hafnium 72 Hf Hafnium spectrum visible.png
|
||||
tantalum 73 Ta Tantalum spectrum visible.png
|
||||
tungsten 74 W Tungsten spectrum visible.png
|
||||
rhenium 75 Re Rhenium spectrum visible.png
|
||||
osmium 76 Os Osmium spectrum visible.png
|
||||
iridium 77 Ir Iridium spectrum visible.png
|
||||
platinum 78 Pt Platinum spectrum visible.png
|
||||
gold 79 Au Gold spectrum visible.png
|
||||
mercury 80 Hg Mercury spectrum visible.png
|
||||
thallium 81 Tl Thallium spectrum visible.png
|
||||
lead 82 Pb Lead spectrum visible.png
|
||||
bismuth 83 Bi Bismuth spectrum visible.png
|
||||
polonium 84 Po Polonium spectrum visible.png
|
||||
radon 86 Rn Radon spectrum visible.png
|
||||
radium 88 Ra Radium spectrum visible.png
|
||||
actinium 89 Ac Actinium spectrum visible.png
|
||||
thorium 90 Th Thorium spectrum visible.png
|
||||
protactinium 91 Pa Protactinium spectrum visible.png
|
||||
uranium 92 U Uranium spectrum visible.png
|
||||
neptunium 93 Np Neptunium spectrum visible.png
|
||||
plutonium 94 Pu Plutonium spectrum visible.png
|
||||
americium 95 Am Americium spectrum visible.png
|
||||
curium 96 Cm Curium spectrum visible.png
|
||||
berkelium 97 Bk Berkelium spectrum visible.png
|
||||
californium 98 Cf Californium spectrum visible.png
|
||||
einsteinium 99 Es
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
###############################################################################
|
||||
# Script Name: jpg-to-png.sh
|
||||
#
|
||||
# Description:
|
||||
# Recursively scans the current directory for JPG and JPEG images,
|
||||
# converts each image to PNG format using ImageMagick, and removes
|
||||
# the original JPG/JPEG file after a successful conversion.
|
||||
#
|
||||
# The script preserves the original directory structure and creates
|
||||
# PNG files alongside the source images.
|
||||
#
|
||||
# Requirements:
|
||||
# - Bash
|
||||
# - ImageMagick (convert)
|
||||
#
|
||||
# Usage:
|
||||
# Convert all JPG/JPEG files under the current directory:
|
||||
#
|
||||
# ./jpg-to-png.sh
|
||||
#
|
||||
# Example:
|
||||
# Before:
|
||||
# photo.jpg
|
||||
# images/picture.jpeg
|
||||
#
|
||||
# After:
|
||||
# photo.png
|
||||
# images/picture.png
|
||||
#
|
||||
# Notes:
|
||||
# - Original JPG/JPEG files are deleted after conversion.
|
||||
# - Existing PNG files with the same name may be overwritten.
|
||||
# - The script processes files recursively.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
IMG_FOLDER="."
|
||||
|
||||
# Find all JPG/JPEG files recursively
|
||||
IMG_ARR=($(find "${IMG_FOLDER}" -iname '*.jpg' -o -iname '*.jpeg'))
|
||||
|
||||
for IMG in "${IMG_ARR[@]}"; do
|
||||
|
||||
echo "Converting: ${IMG}"
|
||||
|
||||
# Convert JPG/JPEG to PNG
|
||||
convert "$IMG" "$(echo "$IMG" | sed 's/\.[jJ][pP][eE]\?[gG]$/.png/')"
|
||||
|
||||
# Remove original image
|
||||
rm "$IMG"
|
||||
|
||||
done
|
||||
Executable
+115
@@ -0,0 +1,115 @@
|
||||
#!/bin/bash
|
||||
|
||||
###############################################################################
|
||||
# Script Name: rename-images-by-date.sh
|
||||
#
|
||||
# Description:
|
||||
# Renames image files using their original capture timestamp.
|
||||
#
|
||||
# The script:
|
||||
# 1. Scans the target directory for image files.
|
||||
# 2. Reads the EXIF DateTimeOriginal tag using exiftool.
|
||||
# 3. Falls back to the file modification timestamp if EXIF data
|
||||
# is unavailable.
|
||||
# 4. Renames files to the format:
|
||||
#
|
||||
# IMG_YYYYMMDD_HHMMSS.ext
|
||||
#
|
||||
# 5. Automatically resolves filename collisions by appending a
|
||||
# numeric suffix.
|
||||
#
|
||||
# Requirements:
|
||||
# - Bash
|
||||
# - exiftool
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# Process current directory:
|
||||
# ./rename-images-by-date.sh
|
||||
#
|
||||
# Process a specific directory:
|
||||
# ./rename-images-by-date.sh /path/to/images
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# ./rename-images-by-date.sh ~/Pictures
|
||||
#
|
||||
# Result:
|
||||
#
|
||||
# Before:
|
||||
# DSC00123.JPG
|
||||
# Vacation.png
|
||||
#
|
||||
# After:
|
||||
# IMG_20230821_143210.JPG
|
||||
# IMG_20240106_094533.png
|
||||
#
|
||||
# Notes:
|
||||
# - Uses EXIF DateTimeOriginal when available.
|
||||
# - Falls back to the file modification time when EXIF metadata is
|
||||
# missing.
|
||||
# - Preserves the original file extension.
|
||||
# - Prevents overwriting existing files.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# Change to target directory
|
||||
TARGET_DIR="./"
|
||||
|
||||
if [[ -n "$1" ]]; then
|
||||
TARGET_DIR="$1"
|
||||
fi
|
||||
|
||||
cd "$TARGET_DIR" || exit 1
|
||||
|
||||
for file in *.{jpg,jpeg,JPG,JPEG,png,PNG}; do
|
||||
|
||||
# Skip non-existing matches
|
||||
[ -f "$file" ] || continue
|
||||
|
||||
# Extract original capture timestamp from EXIF metadata
|
||||
datetime=$(exiftool -DateTimeOriginal -s3 "$file")
|
||||
|
||||
if [[ -n "$datetime" ]]; then
|
||||
|
||||
# Convert:
|
||||
# 2023:08:21 14:32:10
|
||||
# into:
|
||||
# 20230821_143210
|
||||
formatted=$(
|
||||
echo "$datetime" |
|
||||
sed 's/://g' |
|
||||
sed 's/ /_/g' |
|
||||
cut -c1-15
|
||||
)
|
||||
|
||||
echo "$formatted"
|
||||
|
||||
else
|
||||
|
||||
# Fallback: use file modification timestamp
|
||||
formatted=$(date -r "$file" +"%Y%m%d_%H%M%S")
|
||||
|
||||
fi
|
||||
|
||||
extension="${file##*.}"
|
||||
|
||||
newname="IMG_${formatted}.${extension}"
|
||||
|
||||
# Prevent overwriting existing files
|
||||
if [[ -e "$newname" ]]; then
|
||||
|
||||
i=1
|
||||
|
||||
while [[ -e "IMG_${formatted}_$i.${extension}" ]]; do
|
||||
((i++))
|
||||
done
|
||||
|
||||
newname="IMG_${formatted}_$i.${extension}"
|
||||
fi
|
||||
|
||||
echo "Renaming: '$file' -> '$newname'"
|
||||
|
||||
mv "$file" "$newname"
|
||||
|
||||
done
|
||||
Executable
+98
@@ -0,0 +1,98 @@
|
||||
#!/bin/bash
|
||||
|
||||
###############################################################################
|
||||
# Script Name: resize-images.sh
|
||||
#
|
||||
# Description:
|
||||
# Resizes JPG/JPEG images and converts them to PNG format.
|
||||
#
|
||||
# When no resize argument is supplied:
|
||||
# - Portrait images are resized to fit within 1080px height (x1080)
|
||||
# - Landscape images are resized to fit within 1920px width (1920)
|
||||
#
|
||||
# When a resize argument is supplied:
|
||||
# - The supplied resize value is used for all images.
|
||||
#
|
||||
# Additional features:
|
||||
# - Creates output directory NEW/ automatically.
|
||||
# - Optionally normalizes filenames by replacing spaces with underscores.
|
||||
# - Adds an optional date prefix to generated filenames.
|
||||
# - Converts JPG/JPEG images to PNG.
|
||||
#
|
||||
# Requirements:
|
||||
# - Bash
|
||||
# - ImageMagick (identify, convert)
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# Automatic portrait/landscape sizing:
|
||||
# ./resize-images.sh
|
||||
#
|
||||
# Resize all images to width 2560:
|
||||
# ./resize-images.sh 2560
|
||||
#
|
||||
# Resize all images to height 1440:
|
||||
# ./resize-images.sh x1440
|
||||
#
|
||||
# Output:
|
||||
# NEW/<date>filename.png
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
DATE=$(date +"%d%m%y_")
|
||||
DEFAULT_RESIZE="auto"
|
||||
|
||||
# Use supplied resize value or automatic mode
|
||||
if [[ -n "${1:-}" ]]; then
|
||||
DEFAULT_RESIZE="$1"
|
||||
fi
|
||||
|
||||
# Create output directory
|
||||
mkdir -p NEW
|
||||
|
||||
for file in *.jpg *.jpeg *.JPG *.JPEG; do
|
||||
|
||||
[[ -f "$file" ]] || continue
|
||||
|
||||
# Replace spaces in filenames
|
||||
file_new="$(echo "$file" | tr ' ' '_')"
|
||||
|
||||
if [[ "$file_new" != "$file" ]]; then
|
||||
echo "Rename: $file -> $file_new"
|
||||
mv "$file" "$file_new"
|
||||
fi
|
||||
|
||||
resize_var="$DEFAULT_RESIZE"
|
||||
|
||||
# Automatic resize mode
|
||||
if [[ "$resize_var" == "auto" ]]; then
|
||||
|
||||
dimensions=$(identify -quiet -format "%wx%h" "$file_new" 2>/dev/null)
|
||||
|
||||
width=${dimensions%x*}
|
||||
height=${dimensions#*x}
|
||||
|
||||
if [[ -n "$width" && -n "$height" ]]; then
|
||||
if (( height > width )); then
|
||||
resize_var="x1080"
|
||||
else
|
||||
resize_var="1920"
|
||||
fi
|
||||
else
|
||||
echo "Skipping invalid image: $file_new"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
output="NEW/${DATE}$(basename "${file_new%.*}").png"
|
||||
|
||||
echo "Transform: $file_new -> $output ($resize_var)"
|
||||
|
||||
convert -quiet \
|
||||
"$file_new" \
|
||||
-resize "$resize_var" \
|
||||
"$output"
|
||||
|
||||
done
|
||||
|
||||
echo "Finished."
|
||||
Executable
+99
@@ -0,0 +1,99 @@
|
||||
#!/bin/bash
|
||||
|
||||
###############################################################################
|
||||
# Script Name: screenshot_grab.sh
|
||||
#
|
||||
# Description:
|
||||
# Interactive screenshot capture tool for GNOME desktops.
|
||||
#
|
||||
# The script automatically determines a destination directory from an
|
||||
# open Texmaker project when possible. If no Texmaker project is detected,
|
||||
# the user is prompted to choose a destination folder manually.
|
||||
#
|
||||
# Features:
|
||||
# - Automatic Texmaker project path detection
|
||||
# - Manual directory selection fallback
|
||||
# - User-defined screenshot filenames
|
||||
# - Duplicate filename detection
|
||||
# - Automatic filename copy to clipboard
|
||||
# - Area screenshot capture using gnome-screenshot
|
||||
# - Screenshot preview/confirmation loop
|
||||
#
|
||||
# Requirements:
|
||||
# - Bash
|
||||
# - zenity
|
||||
# - gnome-screenshot
|
||||
# - xclip
|
||||
# - Texmaker (optional)
|
||||
#
|
||||
# Usage:
|
||||
# ./screenshot_grab.sh
|
||||
#
|
||||
# Workflow:
|
||||
# 1. Detect current Texmaker project folder or ask for a directory.
|
||||
# 2. Enter a screenshot filename.
|
||||
# 3. Filename is copied to the clipboard automatically.
|
||||
# 4. Select a screen area using gnome-screenshot.
|
||||
# 5. Confirm the result.
|
||||
# 6. Retake the screenshot until satisfied.
|
||||
#
|
||||
# Output:
|
||||
# <selected_directory>/<filename>.png
|
||||
#
|
||||
# Notes:
|
||||
# - The line beginning with ### contains the default fallback directory.
|
||||
# - Existing filenames are checked before capturing.
|
||||
# - Cancelling any dialog exits the script.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
###/data/DatenLucas/Dokumente/Studium/Master/3.Semester/Mechatronische Systeme/Lernunterlagen/
|
||||
DEFAULT_DIR="$(cat ~/scripts/screenshot_grab.sh | grep "###" | grep -v grep | sed 's/###//g')"
|
||||
cont=1
|
||||
PATH="$(ps -elf | grep -v grep | grep -o -P '(?<=texmaker ).*(?=/.*\.tex)')/"
|
||||
if [ "$PATH" == "/" ]; then
|
||||
# /usr/bin/zenity --error --text="No Filepath detected"
|
||||
# exit 0
|
||||
while [ $cont -eq 1 ]; do
|
||||
PATH="$(/usr/bin/zenity --file-selection --title="No TEX open: Where the FUCK shall I go???" --directory --width=600 --height=400 --filename="$DEFAULT_DIR")"
|
||||
ret=$?
|
||||
if [[ "$PATH" != "/" ]] && [[ -d "$PATH" ]] && [[ $ret -eq 0 ]]; then
|
||||
cont=0
|
||||
elif [[ $ret -eq 1 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
PATH="$PATH/"
|
||||
fi
|
||||
text="Filename exists:"
|
||||
NAME="$(/usr/bin/zenity --entry --ok-label="Fuck" --title="Filename" --text="Enter Name:")"
|
||||
while [ $cont -eq 1 ]; do
|
||||
if [ -a "$PATH$NAME.png" ]; then
|
||||
NEWNAME="$(/usr/bin/zenity --entry --entry-text="$NAME" --cancel-label="Fuck It!" --ok-label="New Fuck" --title="Shit Shit Shit" --text="$text")"
|
||||
ret=$?
|
||||
if [[ "$NEWNAME" == "" ]] && [[ $ret -eq 1 ]]; then
|
||||
cont=0
|
||||
elif [[ "$NAME" != "$NEWNAME" ]] && [[ $ret -eq 0 ]]; then
|
||||
NAME=$NEWNAME
|
||||
cont=0
|
||||
elif [[ "$NAME" == "$NEWNAME" ]] && [[ $ret -eq 0 ]]; then
|
||||
text="I said new name you stupd fucking Idiot"
|
||||
else
|
||||
/usr/bin/zenity --error --title "Fuck Fuck Fuck Error" --text='Some Fucking unexpected State'
|
||||
fi
|
||||
else
|
||||
cont=0
|
||||
fi
|
||||
done
|
||||
if [ "$NAME" == "" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
printf "%s" "$NAME" | /usr/bin/xclip -sel clip
|
||||
NAME="$NAME.png"
|
||||
printf "%s\n" "$PATH$NAME"
|
||||
cont=1
|
||||
while [ $cont -eq 1 ]; do
|
||||
/usr/bin/gnome-screenshot -a -f "$PATH$NAME"
|
||||
/usr/bin/zenity --title="Confirmation" --text="Picture OK?" --ok-label="Fuck Yes" --cancel-label="Fuck No" --question
|
||||
cont=$?
|
||||
done
|
||||
Reference in new issue
Block a user