Remove duplicated code and improve cohesion of ImageResource