Extract common image processing into a module
Properly handle nil image path