Skip to content

Creating a lot of thumbnails with Shell script

This script create a thumbnail with width 100 of each png file in the actual directory.

#!/bin/sh
for i in *.png
do
	echo "convert -thumbnail 100 $i $i"
	convert -thumbnail 100 $i $i
done
Published inenglish

3 Comments

  1. A little hint: if you are using wp_get_attachment_image_src() ftuncion with size and want to get exact thumbnail size: use thumbnail name given in definition (function add_image_size()). If you use array with dimensions WP will use first image size that have proper width or height. So you may get wrong image. Example: instead of 156×98 you might have got 120×98 if you have 2 images defined: 156×98 & 120×98 (height is the same). I fell for it once 😉 Oct 16 ’11 at 15:15

Leave a Reply

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