image optimization script inspired by trimage written in bash