Create images defined by image styles on node save In Drupal 7 I wish to create several images defined by image styles when saving a node. There is only one image field, and it is just several styles of that image that I need to generate.

None of these images are displayed when viewing the node, they will be accessed through XML and Services. 

I think mabye the hook_preprocess_HOOK and theme_image_style can be used as pointed out in this question: Multiple image styles. Is this correct? And if so, can anyone point me to some examples where this is done? In the link above, images are echo'ed out, but is this how it should be done when saving a node?
I ended up creating a separate content type and a theme template file that solved this specific problem I had. I will update this if I ever find a way to do this in a module or other.

EDIT:

I ended up creating a module that solves this. 

in hook_menu:

function mymodule_menu () {
  $items['node/%/generateimages'] = array (
    'title' =&gt; 'Generate images',
    'page callback' =&gt; 'mymodule_generate_images',
    'page arguments' =&gt; array(0, 1),
    'access callback' =&gt; TRUE,
  );
}


In the callback function:

function mymodule_generate_images ($arg1, $arg2) {
  $retval = '';
  $path   = drupal_lookup_path ("source", $arg1 . '/' . $arg2);
  $node   = menu_get_object ("node", 1, $path);

  drupal_set_title ('Generate images ' . $node-&gt;title);

  global $language;
  $lang = $language-&gt;language;
  $files = field_get_items ('node', $node, 'field_image');

  foreach ($files as $key =&gt; $media) : 
    $url   = image_style_url ('related_thumbnail', $media['uri']);
    $thumb = theme ('image_style', array('style_name' =&gt; 'related_thumbnail', 'path' =&gt; $media['uri']));
    $retval .= $thumb;
  endforeach;

  return $retval;
}


After node creation, I manually have to go to thenodeurl/generateimages and images defined in the callback function is created. 

I wish someone could tell me a better way to solve this :)