CUTCODEDOWN
Minimalist Semantic Markup

Welcome Guest
Please Login or Register

If you have registered but not recieved your activation e-mail in a reasonable amount of time, please use our Contact Form for assistance. Include both your username and the e-mail you tried to register with.

Author Topic: Shell script: thumbnail generator using ImageMagick  (Read 28 times)

fgm

  • Newbie
  • *
  • Posts: 13
  • Karma: +2/-0
    • View Profile
Shell script: thumbnail generator using ImageMagick
« on: 26 Nov 2019, 11:04:47 am »
This is the code I wrote some time ago to generate thumbnails for my static sites following Google recommendations. Full sized photos are 1200x800 and the miniatures are shown at 300x200, so I generate double sized thumbnails to be zoom-friendly as Jason recommends:
Code: [Select]
#!/bin/sh
cd /image/directory
for i in `find . -name "*jpg"`;
do
        echo $i;
        convert -resize 600x400 -sampling-factor 4:2:0 -strip -quality 80 -interlace JPEG -colorspace RGB $i -set filename:new '%t_thumb' %[filename:new].jpg;
done

This is the robots.txt entry to avoid getting the thumbnails indexed in Google:
Code: [Select]
User-agent: Googlebot-Image
Disallow: /images/*_thumb.jpg$

 

Advertisement