Which function(s) actually create the physical resized image files? By default, Drupal 7 ships with 3 images styles: thumbnail, medium, and large.



For example, I upload a image file ('abc.jpg') with the image field (I assume the field name is called 'image'); while I am creating an "Article" node, the image file will be uploaded and stored in "sites/default/files/field/image/abc.jpg," and a record of this uploaded file is saved into database in the "file_managed" table.
By that time, the medium and large styles versions of "abc.jpg" is not yet created. 

The teaser of the "Article" node displays the image field with the medium style.



Then, I navigate to the teaser viewmode of that node for the first time. The medium version of "abc.jpg" is generated, and sits in "sites/default/files/styles/medium/public/field/image/abc.jpg."

The default view is set to display the image using the "large" style.



I view the node using its default view, and the large version of "abc.jpg" is created in "sites/default/files/styles/large/public/field/image/abc.jpg."

Basically, the image upload is quite smart; when an image has been upload, Drupal won't create all the different styles version of that image. Drupal only creates the style of an image when you first browse to the view using that specific image style.  

Which functions/hooks are creating the file for the styled images?
The function that generates the image URL basing on the style is theme('image_style'), which is called by theme('image_formatter'), which then called from image_field_formatter_view(); this function is the implementation of hook_field_formatter_view(), the hook that in a field formatter outputs the content of the field in the view for the entity containing that field.

The image is only generated when you access its URL. I tried the following code:

theme("image_formatter", array("image_style" =&gt; "thumbnail", "item" =&gt; array("uri" =&gt; "test.png", "title" =&gt; "Image title", "alt" =&gt; "Alternative text")));


The output that I obtained is the following: 

&lt;img typeof="foaf:Image" src="http://tero.local/dr72/sites/default/files/styles/thumbnail/public/test.png" alt="Alternative text" title="Image title" /&gt;


If you look at the code of image_menu(), you will find the following lines:

  $directory_path = file_stream_wrapper_get_instance_by_scheme('public')-&gt;getDirectoryPath();
  $items[$directory_path . '/styles/%image_style'] = array(
    'title' =&gt; 'Generate image style', 
    'page callback' =&gt; 'image_style_deliver', 
    'page arguments' =&gt; array(count(explode('/', $directory_path)) + 1), 
    'access callback' =&gt; TRUE, 
    'type' =&gt; MENU_CALLBACK,
  );


image_style_deliver() is the function that generates the image.