Created
February 11, 2010 13:54
-
-
Save segellabs/301525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// array of thumbnail images | |
$thumbnails = array('1_a.jpg','2_b.jpg','3_c.jpg','4_d.jpg','5_e.jpg', | |
'6_f.jpg','7_g.jpg','8_h.jpg','9_i.jpg','10_j.jpg'); | |
// set thumbnail path | |
$thumb_dir = '../share/images/'; | |
// set width and height of image output | |
$out_width = 0; | |
$out_height = 0; | |
// look for output width and height | |
foreach ($thumbnails as $thumbnail) { | |
list($width, $height) = getimagesize($thumb_dir.$thumbnail); | |
$out_width += $width; | |
$out_height = ($height >= $out_height) ? $height : $out_height; | |
} | |
// set x-coordinate of destination point | |
$dst_x = 0; | |
// create new true color image | |
$out = imagecreatetruecolor($out_width, $out_height); | |
// copy thumbnail images to new image | |
foreach ($thumbnails as $thumbnail) { | |
$image = imagecreatefromjpeg($thumb_dir.$thumbnail); | |
$x = imagesx($image); | |
$y = imagesy($image); | |
imagecopymerge($out, $image, $dst_x, 0, 0, 0, $x, $y, 100); | |
imagedestroy($image); | |
// move the next thumbnail | |
$dst_x += $x; | |
} | |
// set the content type and render new image | |
header('Content-Type: image/jpeg'); | |
imagejpeg($out); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment