commit 8f526005318dfa7d92c4bfafbae2bb8a4a3a12af
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 30 Oct 2025 00:15:43 +0530
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 30 Oct 2025 00:15:43 +0530
Initial Commit
3 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/README b/README @@ -0,0 +1,6 @@ +onboard-tools +============= +Set of tools to make onboarding of a person into an LDAP server simple. + +genthumbs.sh in_dir [out_dir] - Converts photos from in_dir to out_dir after Wx200 resize +dir2b64.sh in_dir [out_dir] - Populates out_dir the base64 values of all files in in_dir
diff --git a/dir2b64.sh b/dir2b64.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -eu +set -o pipefail + +if [ $# -lt 1 ]; then + echo "Usage: $0 in_dir [out_dir]" >&2 + exit 1 +fi + +in_dir="${1}/" +out_dir="${2:-${in_dir}.base64}" + +if [ ! -d "${out_dir}" ]; then + mkdir ${out_dir} || exit 1 +fi + +for i in "${in_dir}/"*; do + dest="${out_dir}/$(basename $i).b64" + [ -f "$dest" ] && [ "$dest" -nt "$i" ] && continue; + base64 "$i" -w 0 > "${dest}" +done
diff --git a/genthumbs.sh b/genthumbs.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +set -eu +set -o pipefail + +if [ $# -lt 1 ]; then + echo "Usage: $0 in_dir [out_dir]" >&2 + exit 1 +fi + +in_dir="${1}/" +out_dir="${2:-jpgphotos}" + +if [ ! -d "${out_dir}" ]; then + mkdir ${out_dir} || exit 1 +fi + +for i in "${in_dir}/"*; do + ext="${i##*.}" + ext="$(echo ${ext} | tr '[:upper:]' '[:lower:]')" + case ${ext} in + png|jpg|jpeg) + fn="$(basename $i)" + dest="${out_dir}/${fn%.*}.jpg" + # if file exist in destination, make sure it is newer than src + [ -f "${dest}" ] && [ "${dest}" -nt "$i" ] && continue; + if ! magick "$i" -auto-orient -resize x200 -strip "${dest}"; then + printf "%-20s\t=x=> %s\n" "$fn" "$dest" + continue + fi + printf "%-20s\t===> %s\n" "$fn" "$dest" + #exiftool -P -overwrite_original_in_place -Orientation=0 -n "${dest}" + ;; + *) + echo "Convertion done" + ;; + esac +done +
: nply/onboard-tools