Joining 2 or more images side by side with Imagick

I’ve been looking for the method in Imagick to join 2 uploaded images side by side after cropping and resizing.

Does anyone reading this know IF Imagick can do this, and if so, what methods do I need to use to accomplish this?

(documentation for Imagick is deplorable…)

Thanks!

Rubble, thanks.

You are right about the exec() giving me all the options. This works.

I would use exec() as there are a lot more ways of doing things and every option is available. Imagick is still limited to what options have been introduced and the instructions ( can not think of the proper word !! ) are still basic and in some cases incorrect.

If you wanted to use imagick the only way I can think of doing it would be to create a large canvas and put the first image on then add the second image save it and add the third image etc. getting the offsets by using getimagesize().

Again I can not remember the word ( concenate ? ) but you could write your code like:

exec('convert $image1 $image2 -gravity center -background black +append $result'); 

It depends what actual effect you are after.

I have examples of most of the Imagemagick operators using php here:Imagemagick operators

I would guess it can not be done yet.

This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.

A long winded way to do it would be to loop through the images and composite them.

In the command line “append” for side by side would be this:

-append

Join current images vertically or horizontally.
This option creates a single longer image image, by joining all the current images in sequence top-to-bottom. Use +append to stack images left-to-right.
If they are not of the same width, narrower images are padded with the current -background color setting, and their position relative to each other can be controlled by the current [URL=“http://www.imagemagick.org/script/command-line-options.php#gravity”]-gravity setting.

However, I’m not finding an equivalent command option in PHP for side by side, only the direction of the vertical stack.

Well, that was top to bottom… still looking for side-side.

I think I have found what I am looking for… I post it here so that others who have the same question can evaluate this for themselves.

http://us.php.net/manual/en/function.imagick-appendimages.php

Rubble, thanks for your input. I’m not sure what function your are referring to in your post, but how would you go about the long winded way?

Just one more idea… I’m wondering if I could do this using the exec() command…

ie: exec(‘convert ‘.$image1.’ ‘.$image2.’ -gravity center -background black +append result’);