replace sprintf call with snprintf for open image command