Image in binary in the data to WordPress media library

You should use media_handle_sideload. Write your file out to the filesystem then use media_handle_sideload to process it in the same way any other upload is processed. Be sure to cleanup afterwards.

See: https://developer.wordpress.org/reference/functions/media_handle_sideload/#comment-983 for an example