Validate file path extension before using ImageOptim