Cómo redimensionar muchas imagenes al mismo tiempo con resizeallimgs
¿nunca les ha pasado que quieren hacer muchas thumbnails en un directorio rapidamente desde un script? si es asi encontre uno que hace uso de image magick y funciona sensacional lo pego aqui para que todos lo podamos usar :)
#!/bin/sh
# Name: resizeallimgs
# Purpose: resize all jpg or png images in present directory to another sized jpg
# Written by: Rene
# CopyLeft, 2005
# Uses: convert and display commands from ImageMagick
# Syntax: resizeallimgs -j OR -p OR resizeallimgs -h / --help for help
# Example: resizeallimgs -j converts jpgs in directory to resized jpgs
# Example: resizeallimgs -p converts pngs in directory to resized jpgs
# provide help for this script
function useage {
echo -----------------------------------------
echo useage: resizeallimgs -j"|"-p "("jpg or png")"
echo help: resizeallimgs -h "/" resizeallimgs --help
echo creates new jpg files in this directory called '<'filename'>'_thumb.jpg
echo pre-existing images are not changed
echo user prompted for WIDTH of thumbnail image - in pixels - Example: 200
echo thumbnail is scaled proportionately to input dimension
echo " "
echo after resizing you can view a composite image of all resized images
echo answer "'"y"'" or "'"n"'" "("without quotes")" to view a composite of resized images created in the directory
echo Notes: can take some time to display a large number of images
echo " right click on composite display to see next composite page if it exists"
echo " composite display can be saved as a single image and more by left clicking on composite window"
echo -----------------------------------------
echo
}
if [ $1 = "-h" ]; then
useage
exit
fi
if [ $1 = "--help" ]; then
useage
exit
fi
echo "Enter the WIDTH of new images (ex:200)"
read response
if [ $1 = '-j' ]; then
echo JPG images being resized
ls -1 *.jpg | sed "s/\(.*\)\.jpg/\1.jpg \1_thumb.jpg/" |xargs -n 2 convert -resize $response -quality 100 -compress JPEG
fi
if [ $1 = '-p' ]; then
echo PNG images being resized to JPGs
ls -1 *.png | sed "s/\(.*\)\.png/\1.png \1_thumb.jpg/" |xargs -n 2 convert -resize $response -quality 100 -compress JPEG
fi
# Ask if user wants to view a composite of all new jpg images
echo "Do you want to display all thumbnails created in this directory?(y/n)"
read displayall
if [ $displayall = "y" ]; then
display 'vid:*_thumb.*'
exit
fi
exit
este script se puede encontrar aqui: http://www.w-3productions.com/resizeallimgs y fue creado por Rene



La versión estable más reciente de Mandriva (2011) se publicó el 29 de agosto de 2011.
Comentarios
1 comentario escritosQuizás te pueda interesar también iGal, está curiosete.
--