Refactoring images