2023-08-30 19:25:46 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# To use this program, pleas supply an initial image, then the number of cuts
|
|
|
|
# You want.
|
|
|
|
|
2023-08-31 11:26:07 -04:00
|
|
|
if [ "$#" -ne 3 ]; then
|
2023-08-31 22:41:54 -04:00
|
|
|
echo "Usage: $0 <source_image> <width> <height> <file_prefix>"
|
2023-08-31 11:26:07 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-08-31 22:41:54 -04:00
|
|
|
# Set variables
|
|
|
|
w=$2
|
|
|
|
h=$3
|
2023-08-30 19:25:46 -04:00
|
|
|
file_prefix=$4
|
2023-08-30 22:43:42 -04:00
|
|
|
|
|
|
|
|
2023-08-31 22:41:54 -04:00
|
|
|
convert $inputjpg -gravity center -extent "${w}x${h}" output.jpg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# vert_size=`echo "$height/($no_h_slices+1)" | bc -l`
|
|
|
|
# hort_size=`echo "$width/($no_v_slices+1)" | bc -l`
|
|
|
|
|
|
|
|
# echo $vert_size
|
|
|
|
# echo $hort_size
|
2023-08-31 11:26:07 -04:00
|
|
|
|
|
|
|
for ((size=1; size<=num_sizes; size++)); do
|
|
|
|
width=$((size * 100))
|
|
|
|
height=$((size * 100))
|
|
|
|
|
|
|
|
output_filename="${output_base_name}_${width}x${height}.jpg"
|
|
|
|
|
|
|
|
# Use 'convert' command to resize the image
|
|
|
|
convert "$source_image" -resize "${width}x${height}" "$output_filename"
|
|
|
|
|
|
|
|
echo "Created: $output_filename"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "All images created successfully."
|