shell script to create thumbnail

create sh file from shell(via putty) by following command

sudo nano create_image_thumb.sh

========================================================

#!/bin/bash
THUMBS_FOLDER=/home/path/public_html/images_thumb
for file in /home/path/public_html/images/*
do
if [ -f “${THUMBS_FOLDER}/$(basename “$file”)” ]
then
echo “found.”
else
echo “${THUMBS_FOLDER}/$(basename “$file”) not found.”
convert “$file” -resize 250×215^ “${THUMBS_FOLDER}/$(basename “$file”)”
fi
done

==============================================================

press ctrl +x and press y to save

you can used this sh file from cron script by command

  • * 12 * * * sh -x /home/path of sh/create_image_thumb.sh – it execute on every 12 hr once a day
  • *  0,12 * * * sh -x /home/path of sh/create_image_thumb.sh – it execute on every 12 hr twice a day

You need to install imagemagick lib on server for it.

 

Leave a Reply

Your email address will not be published. Required fields are marked *