refactored CookedPostProcessor

- [x] refactored the `CookedPostProcessor`
- [x] refactored the specs
- [x] fixed the: duplicate key value violates unique constraint "index_optimized_images_on_upload_id_and_width_and_height"