Detect the width and height of an image in a stream