Created
April 13, 2023 02:58
-
-
Save jvyden/42c15477b8a752804d02997847542372 to your computer and use it in GitHub Desktop.
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 | |
# generate a random 12-character string | |
output_dir="output" | |
# create the output directory | |
mkdir "$output_dir" | |
# loop through all the .jpg and .png files in the current directory | |
for file in *.jpg *.png *.jpeg; do | |
# get the file extension | |
ext=${file##*.} | |
# check if the file is a .jpg or .png | |
if [[ "$ext" == "jpg" || "$ext" == "png" || "$ext" == "jpeg" ]]; then | |
# resize the image to fit within 640x480 and save it as a .png file in the output directory | |
convert "$file" -resize 640x480 "$output_dir/$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1).png" | |
fi | |
done | |
# loop through all the .png files in the output directory | |
for file in "$output_dir"/*.png; do | |
# run the "optipng" utility on the file to optimize its size | |
optipng "$file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment