DNM: implement object map for tracking used image objects

Branch based up wip-8902 branch (#2699). Unique commits start at 38ebaa7.
Do we need to return a another code to indicate that we don't update it successfully?