A greedy .*: prefix drags grep's lazy match to the second "image data" in file output. Anchor with \A and one lazy quantifier, or switch to file --mime-type for stable, scriptable results.