I've got a customers site that uses an underlay to place pictures of different sizes onto a white background. I've defined an image style that resizes the image and uses and underlay of a blank white image using x offset = center and y offset = center. The images are a mixture of portrait and landscape format and the final image needs to be landscape so the required image, when portrait, is of a centered image with white bands left and right.
Working site.
With 7.x.0.0, as above this is working as required. After warnings about an unsupported module I upgraded to 7.x.1.0. However the images are no longer placed in the center of the background but, typically, are placed partially outside the final image itself. In some cases it looks as though if the image is smaller than the background the center of the image is placed at the left side of the image. Not sure if this is true though.
The test site with the broken image processing is here:
Broken site.
I had to adjust the path to the background image used during the upgrade but I can't get the center attribute to work correctly.
If I try left instead of center all works as I would expect however, right seems to give the same result as center.
When I revert to the old module things work again as expected.
I'm using the GD toolkit, and the Image style is:
Scale 600x400
Underlay (background) xpos:right , ypos:center alpha:100%. file: sites/coralphotography.co.uk/files/image_gallery/background-white.png, dimensions:maximum
The old module just reports the later as:
Underlay (background)
Am I missing something, using the style incorrectly or is this a bug?
Donald.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | image-style-settings-for-underlay.png | 34.69 KB | nelslynn |
| #15 | debug-of-imageMagick-issue.png | 53.52 KB | nelslynn |
| #15 | issue-using-imageMagick.png | 587.49 KB | nelslynn |
| #15 | works-fine-with-gd.png | 182.98 KB | nelslynn |
| #12 | Screen shot 2014-10-12 at 1.20.14 AM copy.png | 120.93 KB | nelslynn |
Comments
Comment #1
dman commentedFirst, great issue report, and second, bravo for having a test site!!!
Hm, underlay of a white image vs 'define canvas' white. ...
Yep, I can confirm that it looks like the 'center' alignment is placing the overlay image at the 'origin' (x=0,y=0 point, not the center. Possible cause for this would be being unable to get the dimensions for the underlay image at the time it does its calculations.
I just did a trial and can confirm that the 'center' positioning on 'define canvas' is not working as expected for me either. :using ImageMagick
I thought we had that OK, in ImageMagick even, a little while back.
Comment #2
dman commentedOn testing, it seems like it's not that it positions itself with 0x0 data, it's that it positions itself with *negative* the expected indent.
So may be related to the way the keyword 'center' is calculated on image+underlay when usually it's image+overlay for the maths.
The REVERSE flag that goes in to the image_overlay() function looks like it needs to have some influence on not just the top/bottom order, but the maths also.
Not's think anything serious would have changed in that respect (keyword maths imagecache_actions_keyword_filter() ) in the 7.x-0.0 to 7.x-1.0 release though. have to check that I guess.
Comment #3
jenlamptonI can confirm the same thing happening on my site, only I'm using GD so it is not related to ImageMagic.
Downgrading to imagecache_actions 7.x-1.0-alpha2 did not resolve the issue.
Downgrading to imagecache_actions 7.x-1.0-alpha1 caused error "undefined function canvasactions_find_file"
Downgrading to imagecache_actions 7.x-0.0 solves the problem.
So the change is between 0.0 and aplha2 :)
Comment #4
epieddy commentedHi,
I have made a patch.
Hope it will resolve your bug.
Comment #5
epieddy commentedComment #6
dman commentedThat smells like it could be what is needed!
Comment #7
fietserwinOK, tested, confirmed and committed. Thanks epieddy.
Comment #9
jenlamptonWorks for me too, thanks for the fix! Will a new release be coming out soon?
Comment #10
fietserwinYes, though that might depend a bit on what you mean with soon :)
I'm going through the open bug reports for 7.x now (6 issues, most seem relatively easy to solve) and as soon as those are fixed we will release a new official version.
Comment #11
Netskill commentedThank you for the patch... I was searching for a long time...
It works !
Comment #12
nelslynn commentedI have this issue, and this patch no long works. Image floats to the left when set to 'center'. Server has 2014-02-17 version of ImageMagick ( 6.8.8-7 ).
Comment #13
nelslynn commentedMoving back to active.
Comment #14
fietserwinIt woks with me with IM6.8.9-3 on Windows 8.1. Can you post the debug output?
What version of this module are you running (please update that as well)
Comment #15
nelslynn commentedImageCache Actions version 7.x-1.4 and the latest Dev version, 2014-Oct-07 Works fine with GD, but not ImageMagick.
Here's a slight revision to what's happening.
Comment #16
nelslynn commentedchanging version
Comment #17
fietserwinCan you post the debug output as text? And the same for the image style (using the image styles admin sub-module that adds an export option to image styles). Than I can play a bit around locally.
Comment #18
dman commentedThanks for the helpful debug feedback.
A quick look says that we should probably expect our "-gravity None" to be "-gravity Center"
It's certainly possible that all the ImageMagic alignment options were not tested all the way..
This sounds straightforward now you've isolated it.
Comment #20
fietserwinIgnore #19 ... nothing was committed.
Comment #22
fietserwinI finally got to test and ... correct! this on IM. It took some time to find out how to underlay (while increasing the canvas) but it works now.
I tested:
- overlay larger then original
- a number of textual position (top center bottom, left, right)
- numeric offsets with the 4 final dimensions modes.
- overlay smaller then original
- with numeric offsets (textual offsets will fully cover the underlay)
The (simplified) command line looks like:
convert sample.png -resize 200x150! -background "rgba(0, 0, 0, 0)" -extent 300x250-50-50 300x250.jpg -compose dst-over -composite test.jpg.
@nelslynn: Thanks for reporting. Fixed and committed.