2

My aim is to crop an image from right side and append another image to cropped image at the bottom in a single step. What I mean single step is for ex, I used following code to crop image

$ini_filename = "/var/www/html/genome/family/$heatmap";
$im = imagecreatefrompng($ini_filename);

$ini_x_size = getimagesize($ini_filename )[0];
$ini_y_size = getimagesize($ini_filename )[1];

$to_crop_array = array('x' =>0 , 'y' => 0, 'width' => 1216, 'height'=> $width);
$thumb_im = imagecrop($im, $to_crop_array);

imagepng($thumb_im, "/var/www/html/genome/family/$heatmap", 0);

Now, I would like to append another image at the bottom of cropped image before saving to a directory. I found useful code for image appending here. But I am not understanding how can I append an image to the cropped image before executing the line: imagepng($thumb_im, "/var/www/html/genome/family/$heatmap", 0);. Or should I follow crop image, save, again open and append? Can anyone please give suggestion?

Community
  • 1
  • 1
Donjin
  • 79
  • 7

1 Answers1

0

1) Create larger image with height+20

http://www.php.net/manual/en/function.imagecreatetruecolor.php

2) Copy the first image and the second image to the larger image

http://www.php.net/manual/en/function.imagecopy.php

3) Save it

Amorphous
  • 779
  • 7
  • 27