Created
February 13, 2023 02:37
-
-
Save jimmyctk/94c072b18617315fe79a95f730f59dd3 to your computer and use it in GitHub Desktop.
Drag and drop batch image crop and add white space using rust on mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
helpFunction() | |
{ | |
echo "" | |
echo "Usage: $0 1000 100" | |
echo -e "\t [Target Resolution] [Border size]" | |
exit 1 # Exit script after printing help | |
} | |
# Print helpFunction in case parameters are empty | |
if [ -z "$1" ] | |
then | |
echo "Some or all of the parameters are empty"; | |
helpFunction | |
fi | |
# Begin script in case all parameters are correct | |
target_res=$1 | |
resize_res=$(($1-$2)) | |
echo "Drag&Drop files/dirs and press enter when done." | |
IFS="" read -r input | |
eval "files=( $input )" | |
for file in "${files[@]}" | |
do | |
filename=$(basename -- "$file") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
path=$(dirname "$file") | |
autocrop -i $file | |
image-resizer $file -m $1 | |
film-borders --image $file --no-border --width $1 --height $1 --frame-color ffffff --frame-width $2 | |
echo "Done" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment