I'm going a little crazy here. For the life of me I cannot get canvas to apply like it should. Or maybe I'm misunderstanding how it works? Actions are:

Scale 200 width (upscaling allowed)
Define Canvas 300X300 centered, under image, using #333333

See the enclosed picture. Unless I'm misunderstanding how Canvas action works, I should see dark (#333333) bars around the image, no?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brooho’s picture

Confirm.
Define Canvas working in 6.x-1.6 but not working in 6.x-1.7

bomarmonk’s picture

Confirming: reverting to version 6.x-1.6 made canvases apply to the preset. 1.7 does not work!

modctek’s picture

Category: support » bug

Glad I'm not going insane.

Anonymous’s picture

Version: 6.x-1.7 » 6.x-2.0

Neither works with verstion 6.x-2.0.

matthewn’s picture

subscribing

dman’s picture

True,
Something mucked up badly somewhere.
Sorry. I'm looking at that now. in 2.x-dev

... I'm seeing some inconsistency in the arguments that were passed to image_toolkit_invoke() ... in imageapi_image_overlay.inc.
This would also explain the problems folk were seeing with watermark.
( The 'define canvas' action creates a blank/colored image object, then overlays the current image on top of it - using 'overlay' function )
.
..
... Not sure why this would have gone so wrong.

A fix for this issue is now in -2.x-dev. But I'm seeing issues with unrelated imageMagick stuff. ... under development

ermannob’s picture

subscribing. Thanks.

derMatze’s picture

This one is not working 7.x-dev as well, right? :(

fietserwin’s picture

Version: 6.x-2.0 » 7.x-1.x-dev

The 6.x-2.x is not supported anymore and we are closing all issues for it.

As I see all main versions mentioned here, Ileave itopen as an issue, but for 7.x-1.x. Please add a needs backport to D6 tag, if the issue is also still there in the 6.x-1.x branch.

fietserwin’s picture

Status: Active » Closed (cannot reproduce)

Works correctly in D7. I tested it in D6 and got the following warning on trying to add the "define canvas" action:

warning: Parameter 1 to theme_imagecacheactions_rgb_form() expected to be a reference, value given in includes\theme.inc on line 668.

But that error is already reported in #1192318: imagecacheactions_rgb_form() , so closing this issue.

designsbybrandon’s picture

Version: 7.x-1.x-dev » 7.x-1.1
Status: Closed (cannot reproduce) » Active

I am having this same issue with 7.x-1.1. Define canvas does nothing. I am trying to scale and image down 50px on the longest side (working), then place it on a canvas resulting in a non-cropped 50x50 image.

fietserwin’s picture

When I tested it, it seemed to work fine for me. Can you export the styles involved (using the Image styles admin sub module) and paste the strings here?

designsbybrandon’s picture

a:5:{s:4:"isid";s:2:"10";s:4:"name";s:16:"my_product_thumb";s:6:"module";N;s:7:"storage";i:1;s:7:"effects";a:2:{i:29;a:12:{s:5:"label";s:5:"Scale";s:4:"help";s:142:"Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.";s:15:"effect callback";s:18:"image_scale_effect";s:19:"dimensions callback";s:22:"image_scale_dimensions";s:13:"form callback";s:16:"image_scale_form";s:13:"summary theme";s:19:"image_scale_summary";s:6:"module";s:5:"image";s:4:"name";s:11:"image_scale";s:4:"data";a:3:{s:5:"width";s:2:"50";s:6:"height";s:2:"50";s:7:"upscale";i:0;}s:4:"ieid";s:2:"29";s:4:"isid";s:2:"10";s:6:"weight";s:1:"1";}i:30;a:12:{s:5:"label";s:13:"Define canvas";s:4:"help";s:109:"Define the size of the working canvas and background color, this controls the dimensions of the output image.";s:15:"effect callback";s:33:"canvasactions_definecanvas_effect";s:19:"dimensions callback";s:37:"canvasactions_definecanvas_dimensions";s:13:"form callback";s:31:"canvasactions_definecanvas_form";s:13:"summary theme";s:34:"canvasactions_definecanvas_summary";s:6:"module";s:24:"imagecache_canvasactions";s:4:"name";s:26:"canvasactions_definecanvas";s:4:"data";a:4:{s:3:"RGB";a:1:{s:3:"HEX";s:6:"FFFFFF";}s:5:"under";i:0;s:5:"exact";a:4:{s:5:"width";s:2:"50";s:6:"height";s:2:"50";s:4:"xpos";s:6:"center";s:4:"ypos";s:6:"center";}s:8:"relative";a:4:{s:8:"leftdiff";s:0:"";s:9:"rightdiff";s:0:"";s:7:"topdiff";s:0:"";s:10:"bottomdiff";s:0:"";}}s:4:"ieid";s:2:"30";s:4:"isid";s:2:"10";s:6:"weight";s:1:"2";}}}

The result I am getting from a few samples of test:
37x50, 44x50, 50x26, 50x17, 50x14, 39x50

fietserwin’s picture

Status: Active » Closed (works as designed)
FileSize
9.29 KB

You have to define the canvas under the image:
ScreenHunter_32 Dec. 21.jpg

designsbybrandon’s picture

Made the change to 'Resize canvas under image' and still have the same results. Cleared All Caches to ensure.

If I remove my initial scale and just attempt to scale the canvas, I get the original image unaltered -- which is the reason I believe Define Canvas is not doing anything.

a:5:{s:4:"isid";s:2:"10";s:4:"name";s:16:"my_product_thumb";s:6:"module";N;s:7:"storage";i:1;s:7:"effects";a:2:{i:29;a:12:{s:5:"label";s:5:"Scale";s:4:"help";s:142:"Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.";s:15:"effect callback";s:18:"image_scale_effect";s:19:"dimensions callback";s:22:"image_scale_dimensions";s:13:"form callback";s:16:"image_scale_form";s:13:"summary theme";s:19:"image_scale_summary";s:6:"module";s:5:"image";s:4:"name";s:11:"image_scale";s:4:"data";a:3:{s:5:"width";s:2:"50";s:6:"height";s:2:"50";s:7:"upscale";i:0;}s:4:"ieid";s:2:"29";s:4:"isid";s:2:"10";s:6:"weight";s:3:"-10";}i:30;a:12:{s:5:"label";s:13:"Define canvas";s:4:"help";s:109:"Define the size of the working canvas and background color, this controls the dimensions of the output image.";s:15:"effect callback";s:33:"canvasactions_definecanvas_effect";s:19:"dimensions callback";s:37:"canvasactions_definecanvas_dimensions";s:13:"form callback";s:31:"canvasactions_definecanvas_form";s:13:"summary theme";s:34:"canvasactions_definecanvas_summary";s:6:"module";s:24:"imagecache_canvasactions";s:4:"name";s:26:"canvasactions_definecanvas";s:4:"data";a:4:{s:3:"RGB";a:1:{s:3:"HEX";s:6:"FFFFFF";}s:5:"under";i:1;s:5:"exact";a:4:{s:5:"width";s:2:"50";s:6:"height";s:2:"50";s:4:"xpos";s:6:"center";s:4:"ypos";s:6:"center";}s:8:"relative";a:4:{s:8:"leftdiff";s:0:"";s:9:"rightdiff";s:0:"";s:7:"topdiff";s:0:"";s:10:"bottomdiff";s:0:"";}}s:4:"ieid";s:2:"30";s:4:"isid";s:2:"10";s:6:"weight";s:2:"-9";}}}

fietserwin’s picture

FileSize
43.78 KB

What are you expecting? I get the following result (used FF0000 instead of FFFFFF for clarity) which is what should be expected (tested with both GD and Imagemagick):
ScreenHunter_32 Dec. 26.jpg

If you expect something else, please describe what you expect or show us a sample. If you get something else, please post a screenshot of that as well as your configuration (a.o. toolkit, versions, etc.)

designsbybrandon’s picture

FileSize
39.32 KB

You seem to have the result I am expecting, but not what I am getting. My preview shows 50x38 when I am setting to 50x50.

dman’s picture

That clearly does look like a problem. Can't imagine why you get this and we don't.

fietserwin’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Closed (works as designed) » Active

OK, reopening, your site is not working as should.

Can you tell us something more about your configuration:
- this module's version
- toolkit in use
- image toolkit version, i.e. version of Imagemagick (version information on admin/config/media/image-toolkit) or GD (GD info block of phpinfo())
- Operating system and version
- PHP version
- If using Imagemagick, can you enable "Display debugging information" in admin/config/media/image-toolkit?

Can you test on other systems? Can you get it to work on other systems (the export and import features can be useful here)? Any other information that can give us a hint?

Can you debug the code?

designsbybrandon’s picture

- Module version 7.x-1.1
- ImageMagick
- Version 6.5.4-7 2012-05-07 Q16 OpenMP
- CentOS 6 on Virtual Machine using VMWare. This is the development environment for my site.
- PHP 5.3.3

When enabling "Display debugging information" the notice is:
User notice: ImageMagick command:

/usr/bin/convert '/var/www/html/modules/image/sample.png' -resize 50x38! -background '#FFFFFF' -compose src-over -extent 50x50+0-6 -quality '75' '/var/www/html/sites/default/files/styles/my_product_thumb/public/modules/image/sample.png'

in trigger_error() (line 7364 of /var/www/html/includes/common.inc). =>

If i take the command and experiment with it in my terminal window, I can get the 50x50 desired size by modifying '-extent 50x50+0-6' to remove the '+0-6'. That result is not centered, and I dont know where the +0-6 is coming from.

fietserwin’s picture

Can you experiment further and try e.g. -extent 50x50+0+6. This is, btw, the offset part (http://www.imagemagick.org/script/command-line-processing.php#geometry). used to place the canvas behind the image at the correct position (in this case to get it centered). My guess now is that the minus sign is interpreted by the shell before arriving in the convert tool (the subsection "Offsets in geometry" further on in the mentioned webpage does use single quotes...).

designsbybrandon’s picture

All return the same 50x38 result.
-extent 50x50+0-6, -extent 50x50+0+6
-extent 50x50-0-6, -extent 50x50-0+6

Putting single quotes on '50x50+0-6' does nothing to change the output.

fietserwin’s picture

Too bad as that would have been easy to fix. Your imagemagick version is from mid 2009. Can you try to install a newer version and try again?

Can you also try the command with -gravity Center -extent 50x50 (-gravity Center should replace the +0-6)?

As a workaround, so you can continue building your site, you can also try the GD toolkit.

designsbybrandon’s picture

using -gravity Center -extent 50x50 is working, but since these modifications are done manually and in my terminal window, how do I get the style to generate with the needed modifications instead of the original that was exported?

fietserwin’s picture

We first need to know what works and what not, after that we can patch the code.

The problem with -gravity Center is that it only works when the offsets are based on keywords (without any further offset like e.g. "right + 3"). But otoh, when we know that a newer version of imagemagick does work, it is often impossible to have a hoster upgrade it. So we cannot "require" some minimal version of imagemagick. But that would make it at least a well documented bug that we can even warn for.

So, can you still try a newer version of IM?

fietserwin’s picture

Status: Active » Closed (won't fix)

Not sure if you ever tried a newer version of IM or wrote a hack/patch yourself. I changed the code slightly to escape the geometry argument, even if it did not help in your case, but the IM manual advises to always escape geometry arguments.

Changing the code to use -gravity instead of the extended geometry argument, is very difficult as the keywords (center, left, etc.) are already converted to numbers in the code common for all toolkits, thus before the IM specific code is called.

This plus the fact that more recent IM versions do seem to work properly make this a won't fix for me. If someone comes with a proper patch that alleviates the problematic syntax (albeit for specifc cases only), we will change the code.

nelslynn’s picture

I'm experiencing this same issue when using ImageMagick 6.2.8 05/07/12 Q16 or GD2 toolkits.

fietserwin’s picture

This looks like the same error discovered above: an old IM version. On GD2 this should work fine. Are you sure that you flushed the image style (just click on the "Update style" button and press F5 twice on your browser.