#!/usr/bin/env bash working_dir=$(pwd) ep_num=$( echo ${working_dir} | awk -F '_' '{print $2}' ) echo "Settting ep_num=\"${ep_num}\", and working_dir=\"${working_dir}\"" >&2 image_count=0 for found_image in $( find "${working_dir}" -maxdepth 1 -mindepth 1 -type f -exec file --mime-type {} \; | grep image | awk -F ': ' '{print $1}' ) do this_image="${working_dir}/hpr${ep_num}_image_${image_count}" cp -v "${found_image}" "${this_image}" >&2 this_ext="$( file --mime-type ${this_image} | awk -F '/' '{print $NF}' )" mv -v "${this_image}" "${this_image}.${this_ext}" >&2 this_width="$( mediainfo --Full --Output=XML "${this_image}.${this_ext}" | xmlstarlet sel --text --template --match '/_:MediaInfo/_:media/_:track[@type="Image"][1]' --value-of '_:Width' --nl - )" if [ "${this_width}" -gt "400" ] then echo "Generating thumbnail for embedded image \"${this_image}.${this_ext}\"." >&2 magick "${this_image}.${this_ext}" -resize 400x "${this_image}_tn.${this_ext}" echo "

" fi ((image_count=image_count+1)) done