Cant figure out what's wrong with my image style generation code The code outputs and does exactly what I intend it to do, but it throws the following notices:


  Warning: Illegal string offset 'effects' in
  image_style_create_derivative() (line 928 of
  /var/www/html/modules/image/image.module). Warning: Invalid argument
  supplied for foreach() in image_style_create_derivative() (line 928 of
  /var/www/html/modules/image/image.module).


The code I am using is so: 

(Builds the actual image style from base uri if the file doesn't currently exist)

/**
 * Check for and generate image derivatives if none exist.
 *
 * @param string $style
 *   Image style to check.
 * @param string $uri
 *   URI of the base image.
 *
 * @return false|string
 *   Returns uri for the image that should now exist.
 */
function _srv_image_derivitives($style, $uri) {

  // So I have something to return.
  $final_uri = image_style_path($style, $uri);

  // Gets the absolute file name to the file to check for.
  $filename = drupal_realpath($final_uri);

  // If it's not there, make it there.
  if (!file_exists($filename)) {
    $style_load = image_style_load($style);

    if (count($style_load)) {
      image_style_create_derivative(
        $style,
        $uri,
        image_style_path(
          $style,
          $uri
        )
      );
    }
  }
  return $final_uri;
}


(Builds an array of images that will be converted to a json array for an rest post)

/**
 * Build derivatives array from base image uri.
 *
 * @param string $image_uri
 *   The base image to construct.
 *
 * @return array
 *   Array of image derivatives.
 */
function _srv_build_derivative_array($image_uri) {
  // Set up the image styles to be used.
  $image_styles = array(
    'carousel',
    'rotator',
    'leadlandscape',
    'focus',
    'linkthumbnail',
    'topstorythumbnail',
    'topnavthumbnail',
    'lateststoriesthumbnail',
    'headline',
    'subcategorylead',
    'opinionlead',
    'entertainmentlead',
    'entertainmentlatestthumbnail',
    'gallerylandscape',
    'gallerythumbnail',
    'reporterstory',
    'galleryportrait',
  );
  $images_array = array();

  foreach ($image_styles as $key_one =&gt; $style) {
    $image_style_uri = _srv_image_derivitives($style, $image_uri);

    // EFS path instead of public:// uri.
    $images_array[$style] = str_replace("public://", "/data/sites_default_files/", $image_style_uri);
  }
  return $images_array;
}
The first argument should be array in the image_style_create_derivative() function, so the error is in the caller code. 


  Parameters
  
  $style: An image style array.
  
  $source: Path of the source file.
  
  $destination: Path or URI of the destination file.


https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_create_derivative/7.x

There is a incorrect sample in the comments at api.drupal.org.