Theme Image Style for image located in module directory Probably coming at this from too much of a Drupal 6 view point but...

How do I theme an image in a given image style when that image lives in a module folder?  This is driving me batty and I know I'm just missing something simple.

Here is some example code showing what I'm trying to do:

$file_uri = 'public://sites/all/modules/my_module/logo.jpg';
$data['logo'] = theme('image_style', array('style_name' =&gt; 'medium', 'path' =&gt; $file_uri));


Even if I use file_build_uri(), I end up with a path to a file that doesn't exist. If I move the image to the files directory and change the $file_uri to 'public://logo.jpg', it works just fine.

Do I need to copy the image to the files directory as part of the module code?  If so, isn't this ridiculous?

What am I missing?  Is there documentation on how to do something like this?  I've spent over an hour mining the Drupal documentation and came up completely dry.
I just came across this and had to write the code to handle this.

This effectively clones theme_image_style() to create image derivatives during execution of the page request. Generation bypasses the security issues that would otherwise normally trigger a 404, but that also means a slower page the first time the page is visited.

I am only using the public file schema, but I would expect this to fail with the private file schema based styles.

    /**
     * Implements hook_theme().
     */
    function MODULE_theme() {
      return array(
        'remote_image_style' =&gt; array(
          'variables' =&gt; array(
            'style_name' =&gt; NULL,
            'path' =&gt; NULL,
            'width' =&gt; NULL,
            'height' =&gt; NULL,
            'alt' =&gt; '',
            'title' =&gt; NULL,
            'attributes' =&gt; array(),
          ),
        ),
      );
    }

    /**
     * Returns HTML for an image using a specific image style.
     *
     * Clones theme_image_style() with the additional step of forcing the creation
     * of the derivative to bypass any 404 issues.
     */
    function theme_remote_image_style($variables) {
      // Determine the dimensions of the styled image.
      $dimensions = array(
        'width' =&gt; $variables['width'],
        'height' =&gt; $variables['height'],
      );
      image_style_transform_dimensions($variables['style_name'], $dimensions);

      $variables['width'] = $dimensions['width'];
      $variables['height'] = $dimensions['height'];

      $image_style_dest_path = image_style_path($variables['style_name'], $variables['path']);
      if (!file_exists($image_style_dest_path)) {
        $style = image_style_load($variables['style_name']);
        image_style_create_derivative($style, $variables['path'], $image_style_dest_path);
      }
      $variables['path'] = file_create_url($image_style_dest_path);
      return theme('image', $variables);
    }