There is a bug in the imagemask code such that you can/will get MANY errors:

Notice: imagecolorat() [function.imagecolorat]: 0,496 is out of bounds in image_gd_imagemask() (line 111 of /Users/rwohleb/Desktop/WWW/RMCC/docroot/sites/all/modules/imagecache_actions/canvasactions/canvasactions.inc).
Notice: imagecolorat() [function.imagecolorat]: 1,496 is out of bounds in image_gd_imagemask() (line 111 of /Users/rwohleb/Desktop/WWW/RMCC/docroot/sites/all/modules/imagecache_actions/canvasactions/canvasactions.inc).
Notice: imagecolorat() [function.imagecolorat]: 2,496 is out of bounds in image_gd_imagemask() (line 111 of /Users/rwohleb/Desktop/WWW/RMCC/docroot/sites/all/modules/imagecache_actions/canvasactions/canvasactions.inc).

Luckily it's a simple fix. Patch attached.

Comments

lindsayo’s picture

Great happiness and rejoicing! That worked. Thank you, Mr. Wohleb.

filnug’s picture

Sorry if my question is stupid. But I never had to use a patch.
how can I do to use your patch ? paste the code somewhere in the "canvasactions.inc" ?

thank you

fietserwin’s picture

Status: Needs review » Fixed

Current dev version already contains these changes. So marking as fixed.

Status: Fixed » Closed (fixed)

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

paskainos’s picture

Version: 7.x-1.x-dev » 7.x-1.4
Status: Closed (fixed) » Active

I'm seeing this behavior in 7.x-1.4, in spite of the mitigating (patch) code. And what's most confusing is, the two images don't appear to even be different sizes. Any ideas what I'm missing?

fietserwin’s picture

Can you post your image style and the images (1 source and mask) that are giving you this message? Can you also post a few of the messages as well.

Notes:
- Posting the image style is done with the export feature of the image admin sub-module.
- What is your PHP version?

paskainos’s picture

StatusFileSize
new237.37 KB
new34.89 KB
  • PHP 5.3.13
  • Source & mask images attached, respectively.
  • Image style export data:

a:2:{s:4:"name";s:11:"beauty_shot";s:7:"effects";a:3:{i:6;a:3:{s:4:"name";s:24:"smartcrop_scale_and_crop";s:4:"data";a:3:{s:5:"width";s:4:"1200";s:6:"height";s:3:"600";s:7:"upscale";i:0;}s:6:"weight";s:1:"1";}i:7;a:3:{s:4:"name";s:23:"canvasactions_imagemask";s:4:"data";a:1:{s:4:"path";s:25:"public://beauty-alpha.png";}s:6:"weight";s:1:"2";}i:8;a:3:{s:4:"name";s:20:"coloractions_convert";s:4:"data";a:2:{s:6:"format";s:9:"image/png";s:7:"quality";s:2:"50";}s:6:"weight";s:1:"3";}}}

  • DBLog message(s):

Type php
Location ./admin/config/media/image-styles/edit/beauty_shot
Referrer ./admin/config/media/image-styles
Message Notice: imagecolorat() [function.imagecolorat]: 818,530 is out of bounds in image_gd_imagemask() (line 120 of ./sites/all/modules/imagecache_actions/canvasactions/canvasactions.inc).
Severity notice

All the other messages are identical, with the exception of the pixel coordinates (and time/date stamp of course). Let me know if I need to provide more info.

PS don't judge based on the project (image). This project is for a limo service, and the 'creative direction' wasn't our decision.

fietserwin’s picture

I cannot reproduce it on Windows/Apche/Zend PHP5.4 with this GD version (from phpinfo (admin/reports/status/php):
gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.8
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 6b
PNG Support enabled
libPNG Version 1.2.44
WBMP Support enabled
XBM Support enabled

Can you add these 2 lines to the code, just before the double loop:

  drupal_set_message(sprintf("image(%d,%d); mask(%d,%d)", $image->info['width'], $image->info['height'], $mask->info['width'], $mask->info['height']), 'status');
  drupal_set_message(sprintf("image(%d,%d); mask(%d,%d)", imagesx($image->resource), imagesy($image->resource), imagesx($mask->resource), imagesy($mask->resource)), 'status');

and report the results.

Note: images are absolutely not "about the same size", but it should work without warnings.

paskainos’s picture

Done. What results am I reporting?

UPDATE:
Message:
image(1200,600); mask(1200,600)
image(1200,600); mask(1200,600)

Since I can't access (or edit) the image style in the UI, I had to drush image-flush it to get the message to appear (rebuild image(s)).

fietserwin’s picture

- 818,530 is not out of bounds with the images processed at your site.
- The images you provided in #7 are not the same size.
- So you either provided different images or you have a scale effect before applying the mask
Oops. now I see, you use smart scale and crop, that is not our effect and I haven't installed it, so it did not appear in my style. I'll test again today.

You can't access or edit it, but you could export it? Seems strange to me,you must have 'administer image styles' permission to export. If it is a style define by a module (features), you can override it. subsequently by just saving the style without altering it you flush the directory.

paskainos’s picture

I'm not sure I understand, but I'll clarify what I can:

  • The image style in question was manually generated, is 'stand-alone', and is not part of a Feature.
  • Yes, the style uses 3 effects; respectively:
    • Scale and Smart Crop 1200x600 (upscaling allowed) [matching mask img dimensions]
    • Image mask file: public://beauty-alpha.png
    • Change file format Convert to: png
  • Yes, the image style can be exported (reconfirmed) but not edited. Attempts to edit the style via the UI hang, result in performance lag, and generate the dblog notices in question.

UPDATE:
I sincerely apologize for the wasted time. Upon further investigation, the problem was (obviously, above) that effects 2 & 3 were in the wrong order. Hopefully this experience may at least prove useful for other(s) in the future. Thanks, @fietserwin for your help. Sorry for wasting your time.

fietserwin’s picture

This cannot be the source of the problem. Changing the file format can be done at any time in an image style, but has only effect on the save method at the end. Regardless the original image format, it is (a.o.) the mask effect that makes GD to internally start working with alpha transparency, even if the opened image did not have it.

paskainos’s picture

Status: Active » Closed (works as designed)

I am baffled. I deleted the image style in question, and have recreated it a few times using the aforementioned effects, and it works as expected every time. I have no idea what caused the problem was at this point.