Was having problems with the imagecache not creating images. Kept getting this php error

imagejpeg(): 95 is not a valid Image resource in [...]\www\sites\default\modules\imageapi\imageapi_gd.module on line 137.

It appears to be a problem with references not being passed via the call_user_func() functions returned by a number of the imageapi.module functions, in this case imageapi_image_scale().

return call_user_func($image->toolkit .'_image_resize', $image, $width, $height);

I changed it to call_user_func_array() and the problem was resolved.

return call_user_func_array($image->toolkit .'_image_resize', array($image, $width, $height));

I'm running PHP 5.2.6 on Windows. According to http://drupal.org/node/204800#comment-834617 it's noted not every version of PHP is as affected.

Comments

drewish’s picture

i don't see any reason to use either call_user_func() or call_user_func_array(). i'd rather just call it as $function($image, $args) a la #335780: Actions define $image as passed by reference, but call_user_func doesn't support this.

would you mind rolling a patch?

SoeL’s picture

Actually it's strange that change from call_user_func to call_user_func_array helped. In fact it should call the same function but only with the first image object instead of (image_object, width, height)
I have the same problem on windows platform with installed Apache 2.2.9 / PHP 5.2.8
Trying to find the solution for several hours already. For now it really looks like that somewhere in one of the called functions image object is not passed by reference.
BTW: happy Valentine's Day :)

drewish’s picture

Status: Active » Fixed

I committed #396924: Backport fixes from D7 core which should help with this. If not please re-open this issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.