Image optimization before upload

This has been requested by some customers. Putting it here as a reference to a potential solution.