PHP image synthesis

Source: Internet
Author: User
Tags imagecopy

<?php
===================== Create a new GD image stream and output the image ========================
Header ("Content-type:image/png");
function Combine_image ($image 1, $image 2, $opt = 100) {
$wimage _data = getimagesize ($image 1);
$width _im1 = $wimage _data[0];
$height _im1 + = $wimage _data[1];

Switch ($wimage _data[2]) {
Case 1:
$im 1 = @ImageCreateFromGIF ($image 1);
Break

Case 2:
$im 1 = @ImageCreateFromJPEG ($image 1);
Break

Case 3:
$im 1 = @ImageCreateFromPNG ($image 1);
Break
}
$wimage _data = getimagesize ($image 2);
$width _im2 = $wimage _data[0];
$height _im2 + = $wimage _data[1];

$width = min ($width _im1, $width _im2);
$height = $height _im1 + $height _im2;
Switch ($wimage _data[2]) {
Case 1:
$im 2 = @ImageCreateFromGIF ($image 2);
Break

Case 2:
$im 2 = @ImageCreateFromJPEG ($image 2);
Break

Case 3:
$im 2 = @ImageCreateFromPNG ($image 2);
Break
}

$im = Imagecreatetruecolor ($width, $height);
$white = Imagecolorallocatealpha ($im, 255, 255, 255, 127);
Imagefill ($im, 0, 0, $white);

Imagecopy ($im, $im 1, 0, 0, 0, 0, $width, $height _im1);
Imagecopy ($im, $im 2, 0, $height _im1, 0, 0, $width, $height _im2);
//================================================
Header (' Content-type:image/jpeg ');
Imagejpeg ($im, "tpn.jpg");
$output _image = Str_replace ('. ', ' _email. ', $image 1);
Imagedestroy ($im);
Imagedestroy ($im 1);
Imagedestroy ($im 2);
Imagedestroy ($im 3);
Imagedestroy ($im _small);

}
Combine_image (' 11.jpg ', ' 1.jpg ');
?>

PHP image synthesis

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.