A script to resize images with convert.
TODO: add a verification of the arguments
This commit is contained in:
parent
5e1a08bf60
commit
c8600773b3
25
resize_img
Executable file
25
resize_img
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Description: Resize images with avec lower width
|
||||
#
|
||||
# $1: a directory with images to convert or a image file path
|
||||
# $2: the new width size (the height will be proportional)
|
||||
|
||||
TO_RESIZE="${1}"
|
||||
NEW_SIZE="${2}"
|
||||
|
||||
## If the first parameter is a directory
|
||||
if [ -d ${TO_RESIZE} ]; then
|
||||
printf 'Convert all images in %s to %spx width\n' "${TO_RESIZE}" "${NEW_SIZE}"
|
||||
|
||||
## For all images files with the old format in the album directory
|
||||
find "${TO_RESIZE}" -iname "*.png" -o -iname "*.jpg" -exec convert -resize "${NEW_SIZE}" {} {} \;
|
||||
|
||||
else
|
||||
if [ -f ${TO_RESIZE} ]; then
|
||||
printf 'Convert %s to %spx width\n' "${TO_RESIZE}" "${NEW_SIZE}"
|
||||
# Run a find command to ensure it's a png or jpg file
|
||||
find "${TO_RESIZE}" -iname "*.png" -o -iname "*.jpg" -exec convert -resize "${NEW_SIZE}" {} {} \;
|
||||
fi
|
||||
|
||||
fi
|
Loading…
Reference in New Issue
Block a user