我有问题我在框架上创建个人资料图片。但我想制作PNG个人资料图片内框。
http.get
答案 0 :(得分:0)
<?php
/*
Server base directory from which other directories follow
Clearly this is unique to my system so it will need to be
changed to suit environment.
*/
$root='c:/wwwroot';
/*
In practice the image of the girl is likely to be chosen
dynamically somehow - querystring, form submission, database etc
so the paths will clearly need to be changed accordingly.
*/
$images=new stdClass;
$images->frame='/images/css/borders/camera_frame.png';
$images->girl='/images/tmp/girl.jpg';
/* Get the actual image size of the image containing the girl */
list( $w, $h, $t, $a )=getimagesize( $root . $images->girl );
/* Where (x,y) to position the girl */
$px=49;
$py=105;
/* Final blend opacity */
$opacity=100;
/*
The dimensions of the camera screen onto
which the image of the girl will be
superimposed
*/
$nw=236;
$nh=154;
/*
x,y where to place image of girl
*/
$x=0;
$y=0;
/*
Create source images to manipulate
*/
$target = imagecreatefrompng( $root . $images->frame );
$girl = imagecreatefromjpeg( $root . $images->girl );
$copy = imagecreatetruecolor( $nw, $nh );
/*
Resize image of girl to fit viewport of camera
*/
imagecopyresampled( $copy, $girl, 0, 0, 0, 0, $nw, $nh, $w, $h );
/*
Merge the two images to form desired result
*/
imagecopymerge( $target, $copy, $px, $py, $x, $y, $nw, $nh, $opacity );
/*
Output to browser and clean up
*/
header('Content-Type: image/png');
imagepng( $target);
imagedestroy( $target );
imagedestroy( $copy );
imagedestroy( $girl );
?>