timothy (tlord) wrote,

another memory aid / another photo-shrinkage script

Doesn't roll of the tongue like "another day, another dollar" but Hey -- I've got no dollars coming in! Below is my current version of a script it seems I keep re-inventing, which makes me feel like an especially forgetful caveman. This script, for any unixy system with imagemagick, when run from within a directory containing photos (or any jpg images), creates a directory of reduced size (50pct), reduced quality (50pct), black-bordered jpegs in a folder called (duh) "5050versions." The script could be easily modified to be 70/70, 20/90, or whatever combination of size and quality makes sense. I'm sure it'd be easy to make the values for reduction factor and quality level variables to be included when invoking the script ("thumbit 40 60" or suchlike), but, eh, it's late and it works to my satisfaction :) The next thing I'd like to do is make it satisfactorily recursive, which may be more trouble than I want to bother wracking my poor little brain with; I'm picturing the frustrating spurious creation of jillions of directories, or the accidental re-shrinking and re-bordering of images which have already been as shrunken and bordered as I want them to be ... At any rate.





# World's simplest resizing script, standing tenuously on the shoulders of the imagemagick giants :)
# to use, place this script in a directory of pictures you want to resize. Invoke it ("./thumbit5050"). Bam.
# Intended result: 3 directories (for shrunken images, original images, movies)
# first created 20060206 Philadelphia by Tim
# last updated 20060206 Philadelphia by Tim


for img in *.[j,J][p,P][g,G]
do
convert -sample 50%x50% -quality 50 $img 50pct-$img
done

for img in 50*.[j,J][p,P][g,G]
do
convert -bordercolor black -border 15x15 $img frame-$img
done

rm 50pct*[j,J][p,P][g,G]

mkdir 5050versions
mv *50pct* 5050versions/

mkdir full-size
mv *.[j,J][p,P][g,G] full-size/

# mkdir movies
# mv *[a,A][v,V][i,I]




I wish I knew enough to uncomment those last lines without generating an error when this script is run in a directory which happens to not contain any .avi files ...


  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded  

  • 5 comments