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
Additionally, I tried .jpg and the same error as .gif
:((
#2
same here
#3
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
I dont see errors, but imagecache action dont work if in it adds the task "add watermark"
#5
for me the same error on watermark and reflection and your "patch" did not work.
#6
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
same problem here...any plans on an update?
thanks for the great module!
#8
Patch worked for me. Thanks for the great module! It's saved me SO much time.
#9
the replacement worked for me too, Thanks!
#10
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.