Refactor image rendering api