Removed all verbose-mode code to make it easier to transform the code into proper functions, added a CLEANPATH variable to make sure the output file lands where to input file was (bugfix) and used jpegrescan quiet mode instead of piping everything it had to say to dev/null
Split configuration variables into two sections, seperating them by variables that are likely to be touched by a user and those that are required by the program, but are unlikely to receive manual tuning
Removed all usage of backticks and replaced them by proper parenthesis to make the code more readable & nestable
Major rewrite converting old code to funtions, clearing lots of things up and making the script much more reliable by implementing CLI tool autodetection