Ktools PhotoStore batch image regenerate

Ktools PhotoStoreThe Ktools PhotoStore software (www.ktools.net) automatically generates thumbnails, sample and large images with watermarks of the images in the database. If you change the settings regarding the image sizes only newly added images will get the new sizes.

The following simple script regenerates / resizes the thumbnails, sample and large images from the original images. It runs in batch mode, i.e it will work on every image you have in your stock_photos folder. It will overwrite your current i_, s_ and m_-versions of your images without warning. The sizes is set in the script (it does not read the current settings in the manager).

#!/bin/sh
# ps_regenerate.sh for Ktools Photo Store - http://www.ktools.net
# Copyright 2010-12-27 HelTech Communication, Stefan Helander
# http://www.heltech.se
#
# This script may be downloaded from https://nerdia.net and used for free. It is not
# allowed to redistribute this script without written permission.
#
# Requires GraphicsMagick - gm
#
# Regenerates thumbnail, sample and large images for Ktools Photo Store.
# Copy this file to photostoreroot/stock_photos and execute it
# in that folder. If necessary adjust the sizes below.
# !!! WARNING !!! This script overwrites current m_, s_ and i_versons
# of your current images without question.
#
I_SIZE=”150″
S_SIZE=”500″
M_SIZE=”1200″
COMMAND=”gm convert”
FILES=`ls *.jpg | grep -v “^m_” | grep -v “^s_” | grep -v “^i_”`
for FILE in $FILES
do

# Make i_ image
$COMMAND -size $I_SIZE "$FILE" -resize $I_SIZE "i_$FILE"
# Make s_ image
$COMMAND -size $S_SIZE "$FILE" -resize $S_SIZE "s_$FILE"
# Make m_ image
$COMMAND -size $M_SIZE "$FILE" -resize $M_SIZE "m_$FILE"

done