84669인 학습
152542인 학습
20005인 학습
5487인 학습
7821인 학습
359900인 학습
3350인 학습
180660인 학습
48569인 학습
18603인 학습
40936인 학습
1549인 학습
1183인 학습
32909인 학습
사진의 접미사 이름을 직접 변경하면 이런 일이 발생합니다. PS를 통해 접미사 이름을 변경할 수 있으니 답변이 도움이 되었으면 좋겠습니다.
<?php// 获取图文宽degree, 高島和类型// $img='time.jpg';// print_r(getImageInfo($img));// echo '<br />';function getImageInfo($img){ $info= getimagesize($img); $imageinfo=pathinfo($img); $getImageInfo=array( '너비' => ;$info[0], 'height'=>$info[1], 'type'=>$imageinfo['extension'], ); return $getImageInfo;} water('photo.jpeg','watermark.png');function water($img,$water,$pos=9,$tm=100){ $info=getImageInfo($img); $logo=getImageInfo($water); $dst=openImg($img,$info['type']); $src=openImg($water,$logo['type']); ㅋㅋㅋ $x=ceil(($info['너비'] -$logo['width'])/2); $y=0; break; 사례 3: $x=$info['width']-$logo['width']; $y=0; break; 사례 4: $x=0; $y=ceil(($info['height']-$logo[ '높이'])/2) ; break; 사례 5: $x=ceil(($info['width']-$logo['width'])/2); $y=ceil(($info[' height']-$logo['height'])/2); break; case 6: $x=$info['width']-$logo['width']; $y =ceil(($info['height']-$logo['height'])/2); break; 사례 7: $x=0; $y=$info['height ']-$logo['height']; break; 사례 8: $x=ceil(($info['width']-$logo['width'])/2); $y=$info['높이']-$logo['높이']; break; 사례 9: $x=$info['width']-$logo['width']; $y=$info['height']-$logo['height']; break; 케이스 0: 기본값: $x=mt_rand(0,$info['width']-$logo['width']); $y=mt_rand( 0,$y= $info['height']-$logo['height']); break; } imagecopymerge($dst,$src,$x,$y,0,0,$logo['width' ],$logo['height'],$tm);header ('Content-Type:image/jpeg'); imagejpeg($dst); imagedestory($dst); imagedestory($ src);} function openImg($path,$type){ 스위치($type){ 케이스 'jpeg': 케이스 'jpg': 케이스 'pjpeg': $ img=imagecreatefromjpeg($path); break; 케이스 'png': 케이스 'x-png': $img=imagecreatefrompng($path) ; break; 케이스 'gif': $img=imagecreatefromgif($path); break; case 'wbmp': $img=imagecreatefromwbmp($path); break; 기본값: exit('图文类型不支持'); } return $img; }?>
另外课程可用) ,不同在于getImageInfo函数。
<?phpheader("content-type:text/html;charset=utf-8"); water('photo.jpeg','watermark.jpeg');function getImageInfo($path) { $info = getimagesize($path); $data['width'] = $info[0]; $data['height'] = $info[1]; $data['type'] = $info['mime']; return $data;}function openImg($path,$type){ 스위치($type){ 사례 'image/jpeg': 사례 'image/jpg': 사례 'image/pjpeg': $img=imagecreatefromjpeg($path); break; 케이스 '이미지/png' : 케이스 'image/x-png': $img=imagecreatefrompng($path); break; 케이스 'image/gif': $img=imagecreatefrom gif($path); break; 케이스 '이미지/ wbmp': $img=imagecreatefromwbmp($path); break; 기본값: 종료('图文类型不支持'); } return $img; }//$water = 'watermark.jpeg ';함수 water($img,$water,$pos=9,$tm=100){ $info=getImageInfo($img); $logo=getImageInfo($water); $dst=openImg($ img,$info['type']); $src=openImg($water,$logo['type']); 스위치($pos){ 사례 1: $x=0; $y= 0; break; 사례 2: $x=ceil(($info['width']-$logo['width'])/2); $y=0; break; 사례 3 : $x=$info['width']-$logo['width']; $y=0; break; 사례 4: $x=0; $y=ceil(($info['height' ']-$logo['height'])/2); break; 사례 5: $x=ceil(($info['width']-$logo['width'])/2); $y=ceil(($info['height']-$logo['height'])/ 2); break; 사례 6: $x=$info['width']-$logo['width']; $y=ceil(($info['height']-$logo['height '])/2); break; 사례 7: $x=0; $y=$info['height']-$logo['height']; break; 사례 8: $x =ceil(($info['width']-$logo['width'])/2); $y=$info['height']-$logo['height']; break; 사례 9 : $x=$info['width']-$logo['width']; $y=$info['height']-$logo['height']; break; 대소문자 0: 기본값 : $x=mt_rand(0,$info['width']-$logo['width']); $y=mt_rand(0,$y=$info['height']-$logo['height ']); break; } imagecopymerge($dst,$src,$x,$y,0,0,$logo['width'],$logo['height'],$tm); 헤더 ('콘텐츠 유형:이미지/jpeg'); imagejpeg($dst); imagedestory($dst); imagedestory($src);}?>
사진의 접미사 이름을 직접 변경하면 이런 일이 발생합니다. PS를 통해 접미사 이름을 변경할 수 있으니 답변이 도움이 되었으면 좋겠습니다.
<?php
// 获取图文宽degree, 高島和类型
// $img='time.jpg';
// print_r(getImageInfo($img));
// echo '<br />';
function getImageInfo($img){
$info= getimagesize($img);
$imageinfo=pathinfo($img);
$getImageInfo=array(
'너비' => ;$info[0],
'height'=>$info[1],
'type'=>$imageinfo['extension'],
);
return $getImageInfo;
}
water('photo.jpeg','watermark.png');
function water($img,$water,$pos=9,$tm=100){
$info=getImageInfo($img);
$logo=getImageInfo($water);
$dst=openImg($img,$info['type']);
$src=openImg($water,$logo['type']);
ㅋㅋㅋ $x=ceil(($info['너비'] -$logo['width'])/2);
$y=0;
break;
사례 3:
$x=$info['width']-$logo['width'];
$y=0;
break;
사례 4:
$x=0;
$y=ceil(($info['height']-$logo[ '높이'])/2) ;
break;
사례 5:
$x=ceil(($info['width']-$logo['width'])/2);
$y=ceil(($info[' height']-$logo['height'])/2);
break;
case 6:
$x=$info['width']-$logo['width'];
$y =ceil(($info['height']-$logo['height'])/2);
break;
사례 7:
$x=0;
$y=$info['height ']-$logo['height'];
break;
사례 8:
$x=ceil(($info['width']-$logo['width'])/2);
$y=$info['높이']-$logo['높이'];
break;
사례 9:
$x=$info['width']-$logo['width'];
$y=$info['height']-$logo['height'];
break;
케이스 0:
기본값:
$x=mt_rand(0,$info['width']-$logo['width']);
$y=mt_rand( 0,$y= $info['height']-$logo['height']);
break;
}
imagecopymerge($dst,$src,$x,$y,0,0,$logo['width' ],$logo['height'],$tm);
header ('Content-Type:image/jpeg');
imagejpeg($dst);
imagedestory($dst);
imagedestory($ src);
}
function openImg($path,$type){
스위치($type){
케이스 'jpeg':
케이스 'jpg':
케이스 'pjpeg':
$ img=imagecreatefromjpeg($path);
break;
케이스 'png':
케이스 'x-png':
$img=imagecreatefrompng($path) ;
break;
케이스 'gif':
$img=imagecreatefromgif($path);
break;
case 'wbmp':
$img=imagecreatefromwbmp($path);
break;
기본값:
exit('图文类型不支持');
}
return $img;
}
?>
另外课程可用) ,不同在于getImageInfo函数。
<?php
header("content-type:text/html;charset=utf-8");
water('photo.jpeg','watermark.jpeg');
function getImageInfo($path) {
$info = getimagesize($path);
$data['width'] = $info[0];
$data['height'] = $info[1];
$data['type'] = $info['mime'];
return $data;
}
function openImg($path,$type){
스위치($type){
사례 'image/jpeg':
사례 'image/jpg':
사례 'image/pjpeg':
$img=imagecreatefromjpeg($path);
break;
케이스 '이미지/png' :
케이스 'image/x-png':
$img=imagecreatefrompng($path);
break;
케이스 'image/gif':
$img=imagecreatefrom gif($path);
break;
케이스 '이미지/ wbmp':
$img=imagecreatefromwbmp($path);
break;
기본값:
종료('图文类型不支持');
}
return $img;
}
//$water = 'watermark.jpeg ';
함수 water($img,$water,$pos=9,$tm=100){
$info=getImageInfo($img);
$logo=getImageInfo($water);
$dst=openImg($ img,$info['type']);
$src=openImg($water,$logo['type']);
스위치($pos){
사례 1:
$x=0;
$y= 0;
break;
사례 2:
$x=ceil(($info['width']-$logo['width'])/2);
$y=0;
break;
사례 3 :
$x=$info['width']-$logo['width'];
$y=0;
break;
사례 4:
$x=0;
$y=ceil(($info['height' ']-$logo['height'])/2);
break;
사례 5:
$x=ceil(($info['width']-$logo['width'])/2);
$y=ceil(($info['height']-$logo['height'])/ 2);
break;
사례 6:
$x=$info['width']-$logo['width'];
$y=ceil(($info['height']-$logo['height '])/2);
break;
사례 7:
$x=0;
$y=$info['height']-$logo['height'];
break;
사례 8:
$x =ceil(($info['width']-$logo['width'])/2);
$y=$info['height']-$logo['height'];
break;
사례 9 :
$x=$info['width']-$logo['width'];
$y=$info['height']-$logo['height'];
break;
대소문자 0:
기본값 :
$x=mt_rand(0,$info['width']-$logo['width']);
$y=mt_rand(0,$y=$info['height']-$logo['height ']);
break;
}
imagecopymerge($dst,$src,$x,$y,0,0,$logo['width'],$logo['height'],$tm);
헤더 ('콘텐츠 유형:이미지/jpeg');
imagejpeg($dst);
imagedestory($dst);
imagedestory($src);
}
?>