Hi guys,

I got this when trying to set a .gif file as watermark:

warning: imagecopymerge(): supplied argument is not a valid Image resource in .../public_html/drupal/sites/all/modules/imagecache_effects/imageapi.inc on line 90.

And this when trying to set a .png file as watermark:

    * warning: imagealphablending(): supplied argument is not a valid Image resource in .../public_html/drupal/sites/all/modules/imagecache_effects/imageapi.inc on line 85.
    * warning: imagealphablending(): supplied argument is not a valid Image resource in .../public_html/drupal/sites/all/modules/imagecache_effects/imageapi.inc on line 86.
    * warning: imagecopy(): supplied argument is not a valid Image resource in .../public_html/drupal/sites/all/modules/imagecache_effects/imageapi.inc on line 87.

I already tried to modify $image->res to $image->resource but still didn't work.

Can anyone please fix it?

CommentFileSizeAuthor
#10 imagecache_effects.zip12.08 KBkamkejj

Comments

binhcan’s picture

Additionally, I tried .jpg and the same error as .gif

:((

RAFA3L’s picture

same here

mpaler’s picture

Same for reflection.

My system info:

ImageAPI 6.x-1.6
ImageCache 6.x-2.0-beta9
PHP 5.2.5
GD Version bundled (2.0.34 compatible)

UPDATE: Fixed this problem...

The problem (for both watermark & reflection) is the image resource reference in the image object. It needs to point to "resource" not "res". Not sure why it's pointing to "res" as this is clearly not the correct reference as per the php function documentation.

To fix the watermark (please note my system above), you need to change all references, including to marker as following:

function imageapi_gd_image_watermark($image, $marker, $options = array()) {
  // because of a bug? in gd with png images, we have to use another function
  if ($marker->info['mime_type'] == 'image/png' && $options['opacity'] == 100) {
    imagealphablending($image->resource, true);
    imagealphablending($marker->resource, true);
    return imagecopy($image->resource, $marker->resource, $options['x'], $options['y'], 0, 0, $marker->info['width'], $marker->info['height']);
  }
  else {
    return imagecopymerge($image->resource, $marker->resource, $options['x'], $options['y'], 0, 0, $marker->info['width'], $marker->info['height'], $options['opacity']);
  }
}

Same thing for reflection -- change all references to "res" in function imageapi_gd_image_reflection...

I'm not writing a patch because I think we need to know more about this "res" "resource" issue.

off’s picture

I dont see errors, but imagecache action dont work if in it adds the task "add watermark"

flexator’s picture

for me the same error on watermark and reflection and your "patch" did not work.

loze’s picture

I had these errors, the above fixed it for me.
replacing every instance of $marker->res and $image->res with $marker->resource and $image->resource respectively
in imageapi.inc

jjjames’s picture

same problem here...any plans on an update?
thanks for the great module!

eldesigner’s picture

Patch worked for me. Thanks for the great module! It's saved me SO much time.

codigovision’s picture

the replacement worked for me too, Thanks!

kamkejj’s picture

StatusFileSize
new12.08 KB

Here's a zip file with the entire module, but with every instance of *->res changed to *->resource in imageapi.inc. This fixed the errors I was getting that were that same as described here.

DocMartin’s picture

thanks, kamkejj!

- took a bit of searching to find this thread and your fixed module (I'd been trying to create reflection)

okkingaj’s picture

I spent an entire afternoon trying to get reflection to work. Thanks for this solution Kamkejj!!

catofcheshir’s picture

Now with this changes it works for me. Thanks!

lukus’s picture

The fix worked for me too - great work. Thanks.

Would it be possible to add this to the release?

torgospizza’s picture

The fix detailed in #3 also worked for me, using the latest versions of these modules and PHP 5.2.4-2ubuntu5.19.

hollybeary’s picture

the above .zip works for me as well, thank you so much!