Critical errors when setting watermark

binhcan - March 25, 2009 - 11:14
Project:Imagecache Effects
Version:6.x-1.1
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs work
Description

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?

#1

binhcan - March 25, 2009 - 11:17

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

:((

#2

RAFA3L - April 26, 2009 - 23:24

same here

#3

mpaler - May 13, 2009 - 17:39

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.

#4

OFF - June 11, 2009 - 20:55

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

#5

flexator - June 18, 2009 - 08:49

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

#6

loze - July 8, 2009 - 09:05

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

#7

jjjames - July 11, 2009 - 10:06

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

#8

eldesigner - August 8, 2009 - 13:43

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

#9

Codigo Vision - August 11, 2009 - 15:51

the replacement worked for me too, Thanks!

#10

kamkejj - September 16, 2009 - 21:23

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.

AttachmentSize
imagecache_effects.zip 12.08 KB
 
 

Drupal is a registered trademark of Dries Buytaert.