25 lines
785 B
Bash
Executable File
25 lines
785 B
Bash
Executable File
resize_var="x1080"
|
|
DATE=$(date +"%d%m%y_")
|
|
if [ "$1" != "" ]; then resize_var="$1"; fi
|
|
for file in *jpg ; do
|
|
if [ "$1" == "" ]; then
|
|
height="$(identify -quiet ${file} | cut -f3 -d' ' | cut -f2 -d'x')"
|
|
width="$(identify -quiet ${file} | cut -f3 -d' ' | cut -f1 -d'x')"
|
|
if [ "${height}" != "" ] && [ "${width}" != "" ]; then
|
|
if [ ${height} -gt ${width} ]; then
|
|
resize_var="x1080"
|
|
else
|
|
resize_var="1920"
|
|
fi
|
|
fi
|
|
fi
|
|
file_new="$(echo ${file} | tr ' ' '_')"
|
|
if [[ "${file_new}" != "${file}" ]]; then
|
|
echo "Move $file to $file_new"
|
|
mv "$file" "$file_new"
|
|
fi
|
|
echo "Transform $file_new to ${resize_var}"
|
|
if [ ! -d NEW ]; then mkdir "NEW"; fi
|
|
convert -quiet "$file_new" -resize ${resize_var} $(echo "NEW/${DATE}${file_new}" | sed 's/jp[e]\?g/png/g')
|
|
done
|