Page 1 of 1

Re: Tile image horizontally over a bckground vertically cent

Posted: 2013-04-10T15:52:31-07:00
by fmw42
tile the image out to size 500x18 and then composite it over your background using -gravity center.

see
http://www.imagemagick.org/Usage/canvas/#tile
http://www.imagemagick.org/Usage/compose/
http://www.imagemagick.org/Usage/layers/#convert

so

convert background \( -size 500x18 tile:image2tile \) -gravity center -compose over -composite result

In Windows, leave off the two \

Re: Tile image horizontally over a bckground vertically cent

Posted: 2013-04-10T17:19:58-07:00
by anthony
A double backslash is probably because you are using a PHP system call in double quotes.

That API method results in the command being parsed 3 times, PHP, Shell and by IM.

See PHP using Shell Commands, Watch the extra quotes
http://www.imagemagick.org/Usage/api/#php_quotes

Re: Tile image horizontally over a bckground vertically cent

Posted: 2013-04-10T17:27:15-07:00
by fmw42
now i only need to figure out how to tile it for 100% of the destination image (that is the background) width as it is not always 500 px wide
I do not believe there is any way to do that automatically in IM6. (IM7 will likely allow that). You will have to extract the background image width in a separate command and then feed that as a variable to the -size $(Width)x18.

Alternately, make the width larger than any image you want to use. The composite should automatically crop it to fit the background image.

Re: Tile image horizontally over a bckground vertically cent

Posted: 2013-04-10T18:31:27-07:00
by anthony
fmw42 wrote:
now i only need to figure out how to tile it for 100% of the destination image (that is the background) width as it is not always 500 px wide
I do not believe there is any way to do that automatically in IM6. (IM7 will likely allow that).
You can do this in IMv6 by using -distort viewports and virtual pixels to do the tiling..
For example tiling a "rose:" image, across the center of a "logo:" image

Code: Select all

convert logo: -set option:my:width '%[w]'  \
            \( rose: -set option:distort:viewport '%[my:width]x%[h]' \
               -virtual-pixel tile -filter point -distort SRT 0 \) \
            -gravity center -composite show:
Note the first -set is to save the width of the background logo image as a global option so it is available when defining the viewport using the second -set.

EXTRA: if you want to 'roll' the tiled image, you can set offsets to the viewport!



IMv7 will eventually allow you to do the tile much more directly...
For example this will eventually work (but doesn't at this time)

Code: Select all

    magick logo: rose: -size '%wx%[fx:v.h]' +delete \
           tile:rose:  -gravity center -composite  show:
at the moment you can not use % escapes with settings like -size, only with operators.... :-(
Also there is plans for proper 'tiling' operator that uses in-memory images!