refactor bounding rectangle methods and trim gif export