[Gimp-user] Scaling image via the command line
DJ
delphitech at yahoo.com
Sun Jan 25 16:06:05 PST 2009
Hi Tobias, gimp-users,
>> > I wish to scale the 6MP images from my camera to a smaller size say
>> > 600x800 to be loaded into my phone. How can this be done via command
>> > line ? What are the switches (and arguments) to be used ? I have
>> > hundreds of images to be scaled. doing this with the GUI is
>> > impractical.
A possible solution: ImageMagick - Checkout convert, display, identify
http://www.imagemagick.org/script/convert.php
http://www.imagemagick.org/script/command-line-processing.php#geometry
Here's a *sample* Bash script. Perhaps something like this will work in
your situation. Read up on the options for resizing (see links above).
Hope this helps.
#
# Resize images in current directory using ImageMagick convert command
declare -r ImageExt="jpg"
declare -r Tag="600x800"
declare -r NewSubDir="resized-${Tag}"
declare -r IMResizeOpt="600x800!"
# Create directories if not already present
if [ ! -d "${NewSubDir}" ]; then
printf "Make subdirectory %s\n" "${NewSubDir}"
mkdir "${NewSubDir}"
fi
# Loop through all files in current folder
for theCurrentFile in *".${ImageExt}"; do
theNewFile="${NewSubDir}/${theCurrentFile%%.${ImageExt}}-${Tag}.${ImageExt}"
if [ ! -e "$theNewFile" ]; then
printf "Converting '%s' to '%s'\n" "${theCurrentFile}" "${theNewFile}"
convert -resize "${IMResizeOpt}" "${theCurrentFile}" "${theNewFile}"
fi
done
--
__________________________
DJ
More information about the Gimp-user
mailing list