Created
December 7, 2021 13:10
-
-
Save thisbit/55d919aa773d75e8981465aafe98bf9e to your computer and use it in GitHub Desktop.
A simple script for image optimization using FFMPEG (read the comment)
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 | |
echo "WARNING: run this in the folder that contains images" | |
read -p "# IMAGE FILETYPE (type number): | |
(1) jpg | |
(2) png | |
(3) tif | |
(4) all (WARN: works only on raster images) | |
: " format | |
if [[ $format = "1" ]] | |
then | |
filetype="JPG" | |
imagequery="*.[jJ][pP]*[gG]" | |
elif [ $format = "2" ] | |
then | |
filetype="PNG" | |
imagequery="*.[pP][nN][gG]" | |
elif [ $format = "3" ] | |
then | |
filetype="TIFF" | |
imagequery="*.[tT][iI][fF]*" | |
elif [ $format = "4" ] | |
then | |
filetype="ALL IMGS IN FOLDER" | |
imagequery="*" | |
else | |
echo "ERROR, unknown image type" | |
exit | |
fi | |
echo "Got it, it's - $filetype !" | |
read -p "# IMAGE WIDTH (type px numbers only): " width | |
read -p "# IMAGE DESTINATION FOLDER (type folder name): " output | |
mkdir ./"$output"; for f in $imagequery; do ffmpeg -i "$f" -vf scale="$width":-1 "./$output/${f%%}"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Image Resize
Script adds a simple productivity feature to your workflow if you find yourself having to resize multiple files often. Best used if you add a symlink to your machine so it can be ran from any folder.
There are many better solutions then this ... but this one is mine. :D Use it or abuse it if you like.
Bye