View previous topic :: View next topic |
Author |
Message |
Treovo Tux's lil' helper
Joined: 30 Mar 2004 Posts: 88
|
Posted: Wed Jul 06, 2005 6:43 pm Post subject: Recipe: resize batch with Imagemagick |
|
|
How to resize the pictures matching some criteria in the current directory in 4 lines.
Code: |
#!/bin/sh
for picture in `find . -name '*.JPG'`
do
convert $picture -resize 60% $img
done
|
Copy the lines above in a file and save it. Run it using Code: | sh /path/to/the/file | .
The script will look for files matching the search criteria and resize them using convert.
You can adjust the ration or use other command line tools part of Imagemagick like mogrify.
The scripting capabilities of Imagemagick make it the perfect tool for the job.
This is nothing more than my 2 cents to the community, but as those 4 lines have saved the novice that I am a LOT of time...so I thought I'd share it _________________ .: Free your mind and your ass will follow :. |
|
Back to top |
|
|
bgradid Apprentice
Joined: 21 Mar 2005 Posts: 162
|
Posted: Wed Jul 06, 2005 6:55 pm Post subject: |
|
|
i'd heard of the imagemagik library before, but, wow, I didn't know it was this simple to use
many thanks! |
|
Back to top |
|
|
Treovo Tux's lil' helper
Joined: 30 Mar 2004 Posts: 88
|
Posted: Mon Aug 29, 2005 7:28 pm Post subject: |
|
|
For an obscure reason (well I did not take the time to find out why...) the above script stopped to work.
As a result I extended it a bit to better suit my needs. This version will determine the orientation of the image and resize it accordingly. You can replace the size of the image by any other that suits you.
Code: |
#!/bin/sh
for picture in `find ./ -name '*.JPG'`
do
W=`identify -format "%w" $picture`
H=`identify -format "%h" $picture`
echo $picture
echo $W
echo $H
if [ "$W" -gt "$H" ]
then
mogrify $picture -resize 768x576 $picture
else
mogrify $picture -resize 576x768 $picture
fi
done |
_________________ .: Free your mind and your ass will follow :. |
|
Back to top |
|
|
|