Refactored image resizer