I get the following error when viewing an image that uses the Text effect provided by Imagecache Actions.

The selected image handling toolkit imageapi_optimize can not correctly process image_imageapi_optimize_image_effects_text.

It seems that the list of methods provided by _imageapi_optimize_get_methods() is incomplete. Here's a dump of the methods array.

... (Array, 12 elements)

    0 (String, 9 characters ) imagemask
    1 (String, 12 characters ) definecanvas
    2 (String, 7 characters ) overlay
    3 (String, 14 characters ) roundedcorners
    4 (String, 17 characters ) settings_validate
    5 (String, 14 characters ) check_settings
    6 (String, 6 characters ) resize
    7 (String, 6 characters ) rotate
    8 (String, 4 characters ) crop
    9 (String, 10 characters ) desaturate
    10 (String, 10 characters ) create_tmp
    11 (String, 8 characters ) get_info

Adding the following snippet before putting the methods array in the cache solved the problem for me.

  $effects = image_effects();
  foreach ($effects as $effect) {
    $method = $effect['name'];
    if (!in_array($method, $methods)) {
      $methods[] = $method;
    }
  }

Now, the methods array includes all the methods added by imagecache actions, its submodules, and manual crop.


... (Array, 22 elements)

    0 (String, 9 characters ) imagemask
    1 (String, 12 characters ) definecanvas
    2 (String, 7 characters ) overlay
    3 (String, 14 characters ) roundedcorners
    4 (String, 17 characters ) settings_validate
    5 (String, 14 characters ) check_settings
    6 (String, 6 characters ) resize
    7 (String, 6 characters ) rotate
    8 (String, 4 characters ) crop
    9 (String, 10 characters ) desaturate
    10 (String, 10 characters ) create_tmp
    11 (String, 8 characters ) get_info
    12 (String, 11 characters ) image_scale | (Callback) image_scale();
    13 (String, 26 characters ) canvasactions_definecanvas
    14 (String, 16 characters ) image_desaturate | (Callback) image_desaturate();
    15 (String, 25 characters ) canvasactions_canvas2file
    16 (String, 20 characters ) image_scale_and_crop | (Callback) image_scale_and_crop();
    17 (String, 15 characters ) manualcrop_crop
    18 (String, 25 characters ) manualcrop_crop_and_scale
    19 (String, 18 characters ) image_effects_text
    20 (String, 25 characters ) canvasactions_file2canvas
    21 (String, 10 characters ) image_crop | (Callback) image_crop();
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jesss’s picture

There's probably a more elegant way to solve this, but here's a patch to get things rolling.

jesss’s picture

Title: The selected image handling toolkit imageapi_optimize can not correctly process image_imageapi_optimize_image_effects_text. » imageapi_optimize can not correctly process image_imageapi_optimize_image_effects_text
Steven Jones’s picture

Status: Active » Closed (won't fix)

So the root issue here is that imageapi optimise pretends to be another image toolkit by scanning and re-implementing all the functions provided by an image toolkit.
However, image cache actions and in particular the text actions submodule add additional toolkit functions: image_gd_image_effects_text and image_imagemagick_image_effects_text but these are in an include, which probably won't be around when we scan for matching functions. Hence why we never implement this.

This is tricky to resolve and the simplest way would probably be to get image cache actions module to move the implementation of the two image toolkit functions into a .module file.

I think working around the limitations of dynamically defining PHP functions is going to be a horrid affair with tons of edge cases etc. so I'm not sure we should do so in imageapi optimize, sorry.
Version 2.x implements the optimization without defining a new toolkit, so should 'just work' for this use-case.