Check for J2K data before checking for similarity of frames; fixes #599.