-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplace2.php
56 lines (41 loc) · 1.77 KB
/
place2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
# If you don't know the type of image you are using as your originals.
// $image = imagecreatefromstring(file_get_contents('image.png');
// $frame = imagecreatefromstring(file_get_contents('frame.png'));
# If you know your originals are of type PNG.
// $src= imagecreatefrompng('image.png');
// $dest = imagecreatefrompng('frame.png');
// $redimg = imagecreatefrompng('image.png');
// $image = imagecreatefrompng('frame.png');
//set the source image (foreground)
$sourceImage = 'image2.png';
//set the destination image (background)
$destImage = 'place.jpg';
//get the size of the source image, needed for imagecopy()
list($srcWidth, $srcHeight) = getimagesize($sourceImage);
//create a new image from the source image
$src = imagecreatefrompng($sourceImage);
//create a new image from the destination image
$dest = imagecreatefromjpeg($destImage);
//set the x and y positions of the source image on top of the destination image
$src_xPosition = 218; //75 pixels from the left
$src_yPosition = 180; //50 pixels from the top
//set the x and y positions of the source image to be copied to the destination image
$src_cropXposition = 0; //do not crop at the side
$src_cropYposition = 0; //do not crop on the top
//merge the source and destination images
imagecopy($dest,$src,$src_xPosition,$src_yPosition,$src_cropXposition,$src_cropYposition,$srcWidth,$srcHeight);
//output the merged images to a file
/*
* '100' is an optional parameter,
* it represents the quality of the image to be created,
* if not set, the default is about '75'
*/
header( "Content-type: image/jpg");
imagejpeg($dest);
imagejpeg($dest,'final.jpg',100);
//destroy the source image
imagedestroy($src);
//destroy the destination image
imagedestroy($dest);
?>