Image style URL from theme path I am trying to generate a URL for an image style, generated from an image in my theme directory:

$image_uri = drupal_get_path('theme', 'mytheme') . '/images/banners/projects-banner.jpg';
$banner_file = file_build_uri($image_uri);
$banner_url = image_style_url('my_image_style', $banner_file);


The $banner_url looks to be correct, however when I browse to it directly, I get a general Drupal error.

http://www.mysite.local/sites/default/files/styles/my_image_style/public/sites/all/themes/mytheme/images/banners/projects-banner.jpg


I had tried to pass $image_uri into image_style_url, but understand this need a URI and not a path. Can someone please point me in the right direction.
You're right, the image_style_* functions only work with files in the managed file system. You can get round it by using the imagecache_external module, though, which takes remote images and stores them where we need them.

It might seem a little strange to be requesting local images as if they were remote, but this ensures the integrity of the image_style system without further hackery.

$image_uri = drupal_get_path('theme', 'mytheme') . '/images/banners/projects-banner.jpg';

$absolute_image_url = url($image_uri, array('absolute' =&gt; TRUE));
$banner_file = imagecache_external_generate_path($absolute_image_url);

$banner_url = image_style_url('my_image_style', $banner_file);