image_style_url doesn't create images I am using image_style_url to get a thumbnail of a picture I added through the administrator interface.

// $foo-&gt;field_picture['und'][0]['uri'] has value public://foo.jpg
image_style_url('foo-thumb', $foo-&gt;field_picture['und'][0]['uri']);


The API states that the image will be created when the URL is requested. However, when visiting the page the image isn't displayed (404). The URL returned from the function seems to be well formed, but the file hasen't been created.

The 'foo-thumb' folder is in the public data folder and the file permissions should be OK. I tried flushing the image cache (drupal image-flush foo-thumb) but still no results.

Any ideas?
From: https://drupal.org/drupal-7.20-release-notes

In addition, any code which programmatically generates a link to an
image derivative without using the standard image_style_url() API
function will no longer work correctly if the image does not already
exist in the file system, since the necessary token will not be
present in the URL.

Instead you can do something like this;
$image_uri      = $node-&gt;field_image[LANGUAGE_NONE][0]['uri']; // or any public://my_image
$style          = 'my_style';
$derivative_uri = image_style_url($style, $image_uri);
$success        = file_exists($derivative_uri) || image_style_create_derivative(image_style_load($style), $image_uri, $derivative_uri);

$new_image_url  = file_create_url($derivative_uri);