File size: 562 Bytes
712958f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#!/bin/bash
resize_image() {
img="$1"
# Get image dimensions
dimensions=$(identify -format "%wx%h" "$img")
width=$(echo $dimensions | cut -dx -f1)
height=$(echo $dimensions | cut -dx -f2)
# Calculate new dimensions
if (( width < height )); then
new_dim="1024x"
else
new_dim="x1024"
fi
# Resize image with new dimensions
convert "$img" -resize "$new_dim" -filter Lanczos -antialias "${img%.*}_resized.png"
}
export -f resize_image
find /path/to/source/ | parallel -j$(nproc) resize_image {}
|