I want to display an image into three parts as triptych with the help of imagemagick PHP library. I saw the same example here
http://www.rubbleimages.com/Canvas.php.
I am hopeless at PHP but something like this seems to work for me:
#!/usr/local/bin/php -f
<?php
$padding=10;
$info = getimagesize("input.jpg");
$width=$info[0];
$height=$info[1];
// Calculate dimensions of output image
$canvasWidth=$width+4*$padding;
$canvasHeight=$height+2*$padding;
// create white canvas
$output = imagecreatetruecolor($canvasWidth, $canvasHeight);
$background = imagecolorallocate($output, 255, 255, 255);
imagefill($output, 0, 0, $background);
// read in original image
$orig = imagecreatefromjpeg("input.jpg");
// copy left third to output image
imagecopy($output, $orig,$padding, $padding, 0, 0, $width/3, $height);
// copy central third to output image
imagecopy($output, $orig,2*$padding+$width/3, $padding, $width/3, 0, $width/3, $height);
// copy right third to output image
imagecopy($output, $orig,3*$padding+2*$width/3,$padding, 2*$width/3, 0, $width/3, $height);
// save output image
imagejpeg($output,"result.jpg");
?>
If I start with this:
I get this as a result
I added the black outline afterwards so you can see the extent of the image.
$cmd = " convert $photo -crop 33.5%x100% +repage -raise 5x1 "." monet_horizontal_%d.jpg";
exec($cmd);
$cmd = " convert monet_horizontal_0.jpg wt.png monet_horizontal_1.jpg wt.png monet_horizontal_2.jpg +append "." abc.jpg";
exec($cmd);