refactor image api