converted to local a lua function in image_metrics