왜 워터마크를 추가할 수 없고 사진이 출력되지 않나요? 이전 사진을 확대하고 잘라도 작은 상자만 나옵니다.
城南花已开
城南花已开 2018-12-11 15:16:07
0
1
1727
으르르르르


城南花已开
城南花已开

모든 응답(1)
啊啊啊啊啊啊啊啊啊欧

사진의 접미사 이름을 직접 변경하면 이런 일이 발생합니다. PS를 통해 접미사 이름을 변경할 수 있으니 답변이 도움이 되었으면 좋겠습니다.

<?php
// 获取图文宽degree, 高島和类型

// $img='time.jpg';

// print_r(getImageInfo($img));

// echo '<br />';

function getImageInfo($img){

 $info= getimagesize($img);

 $imageinfo=pathinfo($img);

 $getImageInfo=array(

   '너비' =&gt ;$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);
}
?>



최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!