Refactor api image controller