appendImages into rows and columns

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
Zelf
Posts: 12
Joined: 2015-05-12T11:14:41-07:00
Authentication code: 6789

appendImages into rows and columns

Post by Zelf »

I am not using exec command in php so I don't have access to run something like the following from the manual at: http://www.imagemagick.org/Usage/layers/ where it states, "You can take this further to make a whole array of images, and build them either by rows, or by columns."

Code: Select all

convert \( font_1.gif font_2.gif font_3.gif +append \) \
          \( font_4.gif font_5.gif font_6.gif +append \) \
          \( font_7.gif font_8.gif font_9.gif +append \) \
          \( -size 32x32 xc:none  font_0.gif +append \) \
          -background none -append   append_array.gif
Using the http://php.net/manual/en/imagick.appendimages.php appendImages function in imagick how can I simulate the seemingly more robust append CLI command? Or is it not possible.

I would love to be able to create an array in php like the following, loop through it, and each new row somehow tell appendImages when it should start a new row before combining images. Any ideas on how to solve this?

Code: Select all

$rack = [
            'row1' => [
                'image1.jpg',
                'image2.jpg'
            ],
            'row2' => [
                'image3.jpg',
                'image4.jpg'
            ]
        ];
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: appendImages into rows and columns

Post by Bonzo »

I think this is a php problem not an IM one and I would post in a php forum.

I would think you need to loop through your array creating and executing the Imagick code as you go.
Zelf
Posts: 12
Joined: 2015-05-12T11:14:41-07:00
Authentication code: 6789

Re: appendImages into rows and columns

Post by Zelf »

This is a question about the php imagick extension and the imagick appendImages function. How is this not relevant to the php imagick extension programming interface forum?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: appendImages into rows and columns

Post by fmw42 »

Zelf wrote:This is a question about the php imagick extension and the imagick appendImages function. How is this not relevant to the php imagick extension programming interface forum?
I think Bonzo means that it is about PHP looping over the Imagick code. So he is saying to find a PHP forum about looping.
Zelf
Posts: 12
Joined: 2015-05-12T11:14:41-07:00
Authentication code: 6789

Re: appendImages into rows and columns

Post by Zelf »

My question is regarding the appendImages function, not looping. I know how to loop in php, haha!

Here's my question again: When I call appendImages is it possible to somehow tell this function to start a new row. E.g. if I'm looping through my images and I call appendImages(false) - so stacking from left to right - how can I tell appendImages to start a new row say after 3 images?

In ImageMagick from CLI I can set row boundaries with (), how do I mimick this behavior with imagick's implementation of appendImages?

Code: Select all

convert \( font_1.gif font_2.gif font_3.gif +append \) \
          \( font_4.gif font_5.gif font_6.gif +append \) \
          \( font_7.gif font_8.gif font_9.gif +append \) \
          \( -size 32x32 xc:none  font_0.gif +append \) \
          -background none -append   append_array.gif
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: appendImages into rows and columns

Post by fmw42 »

Here's my question again: When I call appendImages is it possible to somehow tell this function to start a new row
Not that I know about, not even in command line mode. That only can be done using montage in command line mode or PHP exec. See http://www.imagemagick.org/Usage/montage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: appendImages into rows and columns

Post by Bonzo »

You could try posting on the forum on this site: http://www.phpimagick.com/ or write some php code to loop over the array as I suggested.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: appendImages into rows and columns

Post by fmw42 »

The only way to start a new row is to +append image horizontally into rows. Then -append the row images vertically into your final set of rows and columns. But I think you know that already. To create rows and columns see the montage function. See http://us3.php.net/manual/en/imagick.montageimage.php
Post Reply