Mengapa saya tidak boleh menambah tera air dan gambar tidak boleh dikeluarkan?
城南花已开
城南花已开 2018-12-11 15:16:07
0
1
1749
<?php
// 获取图片宽度、高度和类型
$img='abc.jpeg';
print_r(getImageInfo($img));
echo '<br/>';
function getImageInfo($img){
  $info= getimagesize($img);
  $imageinfo=pathinfo($img);
  $getImageInfo=array(
    'width' =>$info[0],
    'height'=>$info[1],
     'type'=>$imageinfo['extension'],
    );
    return $getImageInfo;
}
water('abc.jpeg','du.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']);
   switch($pos){
       case 1:
           $x=0;
           $y=0;
           break;
       case 2:
           $x=ceil(($info['width']-$logo['width'])/2);
           $y=0;
           break;
       case 3:
           $x=$info['width']-$logo['width'];
           $y=0;
           break;
       case 4:
           $x=0;
           $y=ceil(($info['height']-$logo['height'])/2);
           break;
       case 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;
       case 7:
           $x=0;
           $y=$info['height']-$logo['height'];
           break;
       case 8:
           $x=ceil(($info['width']-$logo['width'])/2);
           $y=$info['height']-$logo['height'];
           break;
       case 9:
           $x=$info['width']-$logo['width'];
           $y=$info['height']-$logo['height'];
           break;
       case 0:
       default:
           $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){
       switch($type){
           case 'jpeg':
           case 'jpg':
           case 'pjpeg':
               $img=imagecreatefromjpeg($path);
               break;
           case 'png':
           case 'x-png':
               $img=imagecreatefrompng($path);
               break;
           case 'gif':
               $img=imagecreatefromgif($path);
               break;
           case 'wbmp':
               $img=imagecreatefromwbmp($path);
               break;
           default:
               exit('图片类型不支持');
       }
       return $img;
   }
?>


城南花已开
城南花已开

membalas semua(1)
啊啊啊啊啊啊啊啊啊欧

Jika nama akhiran gambar ditukar terus, ini akan berlaku Anda boleh menukar nama akhiran melalui PS Saya harap jawapannya akan membantu.

<?php
// 获取图片宽度、高度和类型

// $img='time.jpg';

// print_r(getImageInfo($img);
/>';

fungsi getImageInfo($img){

 $info= getimagesize($img);

 $imageinfo=pathinfo($img);

 $getImageInfo=array(
  &' ;$info[0],

   'height'=>$info[1],

    'type'=>$imageinfo['extension'],

   );

   return $get Image

air('photo.jpeg','watermark.png');

air berfungsi($img,$air,$pos=9,$tm=100){

  $info=getImageInfo($img);

  $logo=getImageInfo($water);

  $dst=openImg($img,$info['type']);

  $src=openImg($water,$logo['type']);

  suis($pos){

      kes 1:

          $x=0;

          $y=0;

    ;     
patah          $x=ceil(($info['width'] -$logo['width'])/2);

          $y=0;

          break;

      kes 3:

          $th'$info

          $y=0;

          rehat;

      kes 4:

          $x=0;

       ketinggian'])/2) ;. ketinggian']-$logo['tinggi'])/2);

          pecah;

      kes 6:

          $x=$info['lebar']-$logo['lebar'];                                                  =ceil(($info['height']-$logo['height'])/2);

          break;

      kes 7:

          $x=0;
    $  info ']-$logo['ketinggian'];

          pecah;

      kes 8:

          $x=ceil(($info['width']-$logo['width'])/2);
$y=$info['height']-$logo['height'];

          pecah;

      kes 9:

          $x=$info['lebar']-$logo['lebar'];

          $y=$info['tinggi']-$logo['ketinggian'];
          rehat;

      kes 0:

      lalai:

          $x=mt_rand(0,$info['lebar']-$logo['width']-$logo['width' ]); d(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);

}

fungsi openimg ($ path, $ type) {

switch ($ type) {

case 'jpeg':

case 'jpg':

case 'pjpeg':

$ img=imagecreatefromjpeg($path);

              break;

          kes 'png':

          kes 'x-png':
      = laluan);

              rehat;

          kes 'gif': . $path);

              break;

          lalai:

              exit('图片类型不支持');

      }

      return $img;

  }

?>


另外课程上的方法在于getImageInfo函数。

<?php
header("content-type:text/html;charset=utf-8");  
water('photo.jpeg','watermark.jpeg');
fungsi getImageInfo($path) {
   $info = getimagesize($path);
   $data['width'] = $info[0];
$data['height'] = $info[1];
   $data['type'] = $info['mime'];
   return $data;
}
function openImg($path,$type){
suis($type){
          case 'image/jpeg':
          case 'image/jpg':
          case 'image/pjpeg':
              $img= image  );

          kes 'imej/png' :
          kes 'imej/x-png':
              $img=imagecreatefrompng($path);
              patah; imagecreatefromgif($path);
              break;
          case 'image/ '
      }
      pulangkan $img;
  }

//$water = 'watermark.jpeg ';
air berfungsi($img,$air,$pos=9,$tm=100){
  $info=getImageInfo($img);
  $logo=getImageInfo($water);
  $dst=openImg($ img,$info['type']);
  $src=openImg($water,$logo['type']);
  suis($pos){
      kes 1:
          $x=0;
          $ 0 :
$x=$info['width']-$logo['width'];
          $y=0;
          pecah;
      kes 4:
          $x=0;
          pecah; ']-$logo['height'])/2);
          pecah;
      kes 5:
          $x=ceil(($info['width']-$logo['width'])/2);
          $y=ceil(($info['height']-$logo['height'])/ 2);
          pecah;
      kes 6:
          $x=$info['lebar']-$logo['lebar'];
          $y=ceil(($info-$logo['ketinggian'] '])/2);
          pecah;
      kes 7:
          $x=0;
          $y=$info['ketinggian']-$logo['tinggi']; ;        ; ;        ;
          $x =ceil(($info['width']-$logo['width'])/2);
          $y=$info['height']-$logo['height'];
          break;
      case 9 :
          $x=$info['lebar']-$logo['lebar'];
          $y=$info['tinggi']-$logo['tinggi'];
          pecah;
      kes lalai :
          $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);
}
?>





🎜🎜🎜🎜
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!