Frontend post creation including image attachment

Well you have not mentioned whether your code worked or not because the blog you are following is amazing one. And you should have get the solution from that post.

And regarding your question..

require_once(ABSPATH . 'wp-admin/includes/image.php');

This is a core WordPress file which does all the manipulation on images and its meta data.

Why the code is using this file..

The functionalities you need is not a commonly used functionality. That file is being used by WordPress for all manipulation in backend. But when you want to get image from external source or do some manipulation its better to go in WordPress way.

The functions you see in code like wp_generate_attachment_metadata and wp_update_attachment_metadata fully depends on image.php and without these 2 functions image meta data can not be set properly.

I hope this clears the doubt and help you in someway. 🙂