I get this error: The selected image handling toolkit imageapi_optimize can not correctly process imageapi_optimize_image_overlay when I choose an imagecache preset with this actions:

$presets = array();
$presets['mypreset'] = array (
  'presetname' => 'mypreset',
  'actions' => 
  array (
    0 => 
    array (
      'weight' => '0',
      'module' => 'imagecache',
      'action' => 'imagecache_scale',
      'data' => 
      array (
        'width' => '700',
        'height' => '100%',
        'upscale' => 0,
      ),
    ),
    1 => 
    array (
      'weight' => '0',
      'module' => 'imagecache_canvasactions',
      'action' => 'canvasactions_file2canvas',
      'data' => 
      array (
        'xpos' => 'left+10',
        'ypos' => 'bottom+10',
        'alpha' => '90',
        'path' => 'sq_plus_32.png',
      ),
    ),
  ),
);

ImageAPI 6.x-1.9
ImageAPI Optimize 6.x-1.x-dev
Imagecache Actions 6.x-2.x-dev
ImageCache 6.x-2.0-beta10
PHP 5.2.10-2ubuntu6.5 with Suhosin-Patch 0.9.7 (cli)
Drupal 6.19

Comments

jcisio’s picture

This module supports image_overlay since 1.1, but then replaces it with a more general method. Did you go to the ImageAPI Optimize settings page, click Save after you enable the Imagecache Actions so that it is aware of actions introduced by the latter?

Anonymous’s picture

Hi,
sorry for the delay, yes I did what you said, but I get the same error.

Thank you in advance

jcisio’s picture

Status: Active » Postponed (maintainer needs more info)

I don't have any idea why it happens. Can you check if those values are correct? cache_get('imageapi_optimize:methods') should return all implemented methods (including overlay). If not, check _imageapi_optimize_get_methods().

markus_petrux’s picture

Status: Fixed » Postponed (maintainer needs more info)

I have a similar problem with actions provided by ImageCache Actions module, that are located on external .inc files, not present when _imageapi_optimize_get_methods() is invoked. These related functions are loaded by ImageCache module, so a possible solutions would be to do something like this:

 /**
  * Gets all implemented methods by ImageAPI and contrib modules.
  * This function takes a dozens of miliseconds CPU times.
  */
 function _imageapi_optimize_get_methods() {
+  // Load ImageAPI methods that can be located in external files
+  // managed by the ImageCache module.
+  if (module_exists('imagecache')) {
+    foreach (imagecache_action_definitions() as $definition) {
+      if (isset($definition['file'])) {
+        require_once('./'. $definition['file']);
+      }
+    }
+  }

   $funcs = get_defined_functions();
   $methods = array();
   $prefix = variable_get('imageapi_optimize_toolkit', '') .'_image_';

   foreach ($funcs['user'] as $func) {
     if (strpos($func, $prefix) === 0) {
       $method = substr($func, strlen($prefix));
       if (!in_array($method, array('open', 'close'))) {
         $methods[] = $method;
       }
     }
   }
   cache_set('imageapi_optimize:methods', $methods);
   watchdog('imageapi', 'Refresh ImageAPI methods');
   return $methods;
 }

Cheers! :)

[EDITED] to fix the order in which the new lines have to be added. They should go before get_defined_functions() is called.

markus_petrux’s picture

Status: Postponed (maintainer needs more info) » Needs review

Sorry, I forgot to update the issue status.

Temporarily, I'm doing something like that from a custom module and seems to have solved the issue for us.

HTH+

jcisio’s picture

Status: Needs review » Fixed

That's it! Thanks.

markus_petrux’s picture

Thank you! :)

markus_petrux’s picture

Status: Postponed (maintainer needs more info) » Active

I'm sorry, my bad, I made a mistake when posting the patch above in #4.

I have edited the code in #4, to fix the order in which the new lines had to be added. They should go before get_defined_functions() is called.

jcisio’s picture

joran lafleuriel’s picture

Hi all

I am sorry but I couldn't get an overlay action, even if I use the last version where #9 is commited.

Here is what I can read in /var/log/syslog for each image :

Parameter 2 to imageapi_imagemagick_image_overlay() expected to be a reference, value given in my/path/to/modules/imageapi_optimize/imageapi_optimize.module on line 162.

action(id:57): canvasactions_file2canvas failed for sites/default/files/my_image.jpg

Failed generating an image from my_source_image using imagecache preset my_imagecache_preset

This looks like a PHP 5.3 issue...

My config : Ubuntu 11.04, Drupal 6.20, ImageMagick 6.6.2-6, ImageCache 6.x-2.0-beta12, ImageCache Actions 6.x-1.8

Thanks !

jcisio’s picture

I've looked quickly at imagecache_actions module http://drupalcode.org/project/imagecache_actions.git/blob/refs/heads/6.x... and the second parameter is passed by reference. Its signature is different from other actions (where only the first, &$image, is passed by reference).

One solution could be: clone from imageapi_image_overlay to imageapi_optimize_image_overlay. In L21 imageapi_optimize.module, check for function existence before defining new one. It should work, but I can't test now (don't use imagecache_actions, so it'd take time to test).

jcisio’s picture

Status: Fixed » Active
mrfelton’s picture

I get a similar error, but for imagecache_scale_and_crop

gionnibgud’s picture

Same here for imageapi_optimize_image_resize

mstrelan’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

I get this error for any styles. Trying to use Yahoo! Smush It because jpegtran is outside of my open_basedir().

Error message:
The selected image handling toolkit imageapi_optimize can not correctly process image_imageapi_optimize_get_info.

PuntoAndroid’s picture

Suscribing same isse mstrelan and others mention. This would be a great module! I hope i can adress the issue and fix it.

azinck’s picture

As to the issue mentioned in #15 and #16: I'm thinking we need the following on line 303 (at the top of _imageapi_optimize_get_methods() ).
module_load_include('inc','system','image.gd');

esbite’s picture

I also got the error message described in #15. Properly clearing the cache after saving the settings under Image Toolkit solved it for me.

lyricnz’s picture

Status: Active » Closed (duplicate)

The suggestion in #17 is on the right track - imageapi_optimize is not getting a full list of available image_gd_* methods because the GD include file isn't loaded. This was fixed in #1714742: The selected image handling toolkit imageapi_optimize can not correctly process.

-Mania-’s picture

Thanks #18, clearing the caches removed the errors.