How to develop a Python script for automating the process of image resizing and optimization?