# requirements
su - root
apt update
# has the convert command
apt install imagemagick

vim /scripts/create_thumbs.sh 

#!/bin/bash
THUMBS_FOLDER=/path/to/images/thumbnails
for file in /path/to/images/*
do
  # next line checks the mime-type of the file
  IMAGE_TYPE=`file --mime-type -b "$file" | awk -F'/' '{print $1}'`
  if [ x$IMAGE_TYPE = "ximage" ]; then
    IMAGE_SIZE=`file -b $file | sed 's/ //g' | sed 's/,/ /g' | awk '{print $2}'`
    WIDTH=`echo $IMAGE_SIZE | sed 's/x/ /g' | awk '{print $1}'`
    HEIGHT=`echo $IMAGE_SIZE | sed 's/x/ /g' | awk '{print $2}'` 
    #This line convert the image in a 200 x 150 thumb 
    filename=$(basename "$file")
    extension="jpg" # convert every kind type of image to jpg
    # extension="${filename##*.}" # preserve original extension
    filename="${filename%.*}"
    # convert -sample 200x150 "$file" "${THUMBS_FOLDER}/${filename}_thumb.${extension}" 
    # convert -resize 20% "$file" "${THUMBS_FOLDER}/${filename}_thumb.${extension}" 
    echo "=== currently processing $file ==="
    convert -resize 300 "$file" "${THUMBS_FOLDER}/${filename}_thumb.${extension}" 
  fi 
done

manpage

convert.man.txt

admin