I will crawl some data from an XML file and I have all the information I need including the image URL.
There is a function in WordPress called wp_insert_post which is used to create posts programmically. So far, so good. Simple to use:
http://codex.wordpress.org/Function_Reference/wp_insert_post
What I also need is:
- Add an image attached to the post thumbnail by its image URL (for example http://www.test.com/my-image.jpg)
- Resize it on upload with WordPress built in functions (for example max 300 x 300, like medium thumbnail settings
You can use this function for that.
There is a post about this here.
And in the theme you can use this function for getting the thumb in required size
Read more at codex
Default thumbnail sizes also can be changed, see this.