PHP Merge Pictures

Source: Internet
Author: User

 1 function combineimage ($head _img, $middle _img, $footer _img, $save _path) {2 $source _w = n; 3 $source _h = 1142; 4 Take the head picture size 5 $head _size = getimagesize ($head _img); 6 $head _height = $head _size[' 1 '); 7 $head _width = $head _size[' 0 '); 8 $head _start_x = Floor (($source _w-$head _width)/2)//Head Start position 9//Take the middle picture size $midd _size = getimagesize ($middle _im g) One $midd _height = $midd _size[' 1 '];12 $midd _width = $midd _size[' 0 '];13 $midd _start_y = $head _height-15;//Middle Open  Start y coordinate, because the head of the picture at the bottom of the blank, so minus 1514 $midd _start_x = Floor (($source _w-$midd _width)/2); 15 16//Take the bottom picture size: $foot _size = GetImageSize ($footer _img) $foot _height = $foot _size[1];19 $foot _width = $foot _size[0];20 $foot _start_x = f Loor (($source _w-$foot _width)/2);//Bottom picture x coordinate $foot _start_y = $source _h-$foot _height;//bottom Picture y-coordinate $head = Imag Ecreatefrompng ($head _img), $middle = Imagecreatefrompng ($middle _img); $footer = Imagecreatefrompng ($footer _img   ); 26 27  $BG _img = Imagecreatetruecolor ($source _w, $source _h);//generate background picture $color = Imagecolorallocate ($bg _img, 255, 255, 255); Set white background Imagefill ($BG _img, 0, 0, $color),///background color filled with imagecolortransparent ($BG _img, $color);//Transparent Imagecopyr     Esampled ($BG _img, $head, $head _start_x,0,0,0, $head _width, $head _height, $head _width, $head _height); 32 Imagecopyresampled ($BG _img, $middle, $midd _start_x, $midd _start_y,0,0, $midd _width, $midd _height, $midd _width, $midd _ height); imagecopyresampled ($bg _img, $footer, $foot _start_x, $foot _start_y,0,0, $foot _width, $foot _height, $foot _ width, $foot _height), Imagepng ($bg _img, $save _path),}37 $head = dirname (__file__). ' /public/images/head.png '; $midd = DirName (__file__). ' /public/images/midd1.png '; $foot = DirName (__file__). ' /public/images/foot1.png '; $save _path = DirName (__file__). " /public/images/testcomblie.png combineimage ($head, $midd, $foot, $save _path);

PHP merge pictures (go)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.