php動圖
1. php怎麼用ffmpeg.exe動態截圖
$movie = new ffmpeg_movie('4.mp4');
$width=$movie->getFrameWidth();
$height=$movie->getFrameHeight();
$count= $movie->getFrameCount();
print $count . '';
$n = round ( $count/16 );
print $n . '';
for ( $i = 1; $i <= 1; $i ++ ) {
  $img = 'screencap' . $i . '.png';
  $x = $n * $i;
  $f = $movie->getFrame($x);
  $gd_image = $f->toGDImage();
  imagepng($gd_image, $img);
  imagedestroy($gd_image);
  echo "
\n";
}
$extension = "ffmpeg";
$extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
$extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
// load extension
if (!extension_loaded($extension)) {
  dl($extension_soname) or die("Can't load extension $extension_fullname\n");
}
if (php_sapi_name() != 'cli') {
  echo '
';
}
printf("ffmpeg-php version string: %s\n", FFMPEG_PHP_VERSION_STRING);
printf("ffmpeg-php build date string: %s\n", FFMPEG_PHP_BUILD_DATE_STRING);
printf("libavcodec build number: %d\n", LIBAVCODEC_BUILD_NUMBER);
printf("libavcodec version number: %d\n", LIBAVCODEC_VERSION_NUMBER);
print_class_methods("ffmpeg_movie");
print_class_methods("ffmpeg_frame");
// get an array for movies from the test media directory
$movies = getDirFiles(dirname(__FILE__) . '/tests/test_media');
echo "--------------------\n\n";
foreach($movies as $movie) {
  $mov = new ffmpeg_movie($movie);
  printf("file name = %s\n", $mov->getFileName());
  printf("ration = %s seconds\n", $mov->getDuration());
  printf("frame count = %s\n", $mov->getFrameCount());
  printf("frame rate = %0.3f fps\n", $mov->getFrameRate());
  printf("comment = %s\n", $mov->getComment());
  printf("title = %s\n", $mov->getTitle());
  printf("author = %s\n", $mov->getAuthor());
  printf("right = %s\n", $mov->getCopyright());
  printf("get bit rate = %d\n", $mov->getBitRate());
  printf("has audio = %s\n", $mov->hasAudio() == 0 ? 'No' : 'Yes');
  if ($mov->hasAudio()) {
    printf("get audio stream id= %s\n", $mov->getAudioStreamId());
    printf("get audio codec = %s\n", $mov->getAudioCodec());
    printf("get audio bit rate = %d\n", $mov->getAudioBitRate());
    printf("get audio sample rate = %d \n", $mov->getAudioSampleRate());
    printf("get audio channels = %s\n", $mov->getAudioChannels());
  }
  printf("has video = %s\n", $mov->hasVideo() == 0 ? 'No' : 'Yes');
  if ($mov->hasVideo()) {
    printf("frame height = %d pixels\n", $mov->getFrameHeight());
    printf("frame width = %d pixels\n", $mov->getFrameWidth());
    printf("get video stream id= %s\n", $mov->getVideoStreamId());
    printf("get video codec = %s\n", $mov->getVideoCodec());
    printf("get video bit rate = %d\n", $mov->getVideoBitRate());
    printf("get pixel format = %s\n", $mov->getPixelFormat());
    printf("get pixel aspect ratio = %s\n", $mov->getPixelAspectRatio());
    $frame = $mov->getFrame(10);
    printf("get frame = %s\n", is_object($frame) ? 'true' : 'false');
    printf(" get frame number = %d\n", $mov->getFrameNumber());
    printf(" get frame width = %d\n", $frame->getWidth());
    printf(" get frame height = %d\n", $frame->getHeight());
  }
  echo "\n--------------------\n\n";
}
if (php_sapi_name() != 'cli') {
  echo '';
}
/* FUNCTIONS */
function print_class_methods($class) {
  echo "\nMethods available in class '$class':\n";
  $methods = get_class_methods($class);
  if (is_array($methods)) {
    foreach($methods as $method) {
      echo $method . "\n";
    }
  } else {
    echo "No Methods Defined\n";
  }
}
function getDirFiles($dirPath)
{
  if ($handle = opendir($dirPath))
  {
    while (false !== ($file = readdir($handle))) {
      $fullpath = $dirPath . '/' . $file;
      if (!is_dir($fullpath) && $file != "CVS" && $file != "." && $file != "..")
        $filesArr[] = trim($fullpath);
    }
    closedir($handle);
  }
  return $filesArr;
}
?>
2. php如何下載動態圖片保存到本地
php 遠程下載文件    
function http($url, $file="", $timeout=60) {
    $file = empty($file) ? pathinfo($url,PATHINFO_BASENAME) : $file;
    $dir = pathinfo($file,PATHINFO_DIRNAME);
    !is_dir($dir) && @mkdir($dir,0755,true);
    $url = str_replace(" ","%20",$url);
    if(function_exists('curl_init')) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $temp = curl_exec($ch);
        if(@file_put_contents($file, $temp) && !curl_error($ch)) {
            return $file;
        } else {
            return false;
        }
    } else {
        $opts = array(
            "http"=>array(
            "method"=>"GET",
            "header"=>"",
            "timeout"=>$timeout)
        );
        $context = stream_context_create($opts);
        if(@($url, $file, $context)) {
            //$http_response_header
            return $file;
        } else {
            return false;
        }
    }
}
3. php迅速做簡單的動態網站( 只需要 能夠在後台更新文字和圖片)
這們朋友,你要實現更新文字和圖片功能,需要有知道以下知識點:
1)資料庫的增刪改查操作;
2)使用PHP對資料庫進行操作(涉及到表單提交);
3)用PHP使結果循環遍歷輸出;
4)分頁功能實現;
5)文件上傳(主要針對圖片更新)
以上幾點你只要會了,你所說的功能就可以簡單實現。當然,還有個笨辦法,就是你做靜態網頁,要添加的內容可以用DW的可視化編輯添加好內容然後上傳到伺服器後做好相關鏈接,這樣就不涉及到資料庫操作,也不用PHP,只是每次更新的內容只存在靜態網頁中,無法保存到資料庫里。兩者你可以任選其一了。
(Mekbo【麥客博】)
4. php 如何讓gif動圖轉換為gif靜圖
以下是一個縮略圖生成程序,我加了注釋,動態gif動畫處理後就變成靜態了,程序還可以加水印,當然傳參你留空就不會加了。使用有困難的話給我留言。
-----------------------------
/*構造函數-生成縮略圖+水印,參數說明:$srcFile-圖片文件名,$dstFile-另存文件名,$markwords-水印文字,$markimage-水印圖片,$dstW-圖片保存寬度,$dstH-圖片保存高度,$rate-圖片保存品質*/
function makethumb($srcFile,$dstFile,$dstW,$dstH,$rate=100,$markwords=null,$markimage=null) 
{ 
$data = GetImageSize($srcFile); 
switch($data[2]) 
{ 
case 1: 
$im=@ImageCreateFromGIF($srcFile); 
break; 
case 2: 
$im=@ImageCreateFromJPEG($srcFile); 
break; 
case 3: 
$im=@ImageCreateFromPNG($srcFile); 
break; 
} 
if(!$im) return False; 
$srcW=ImageSX($im); 
$srcH=ImageSY($im); 
$dstX=0; 
$dstY=0; 
if ($srcW*$dstH>$srcH*$dstW) 
{ 
$fdstH = round($srcH*$dstW/$srcW); 
$dstY = floor(($dstH-$fdstH)/2); 
$fdstW = $dstW; 
} 
else 
{ 
$fdstW = round($srcW*$dstH/$srcH); 
$dstX = floor(($dstW-$fdstW)/2); 
$fdstH = $dstH; 
} 
$ni=ImageCreateTrueColor($dstW,$dstH); 
$dstX=($dstX<0)?0:$dstX; 
$dstY=($dstX<0)?0:$dstY; 
$dstX=($dstX>($dstW/2))?floor($dstW/2):$dstX; 
$dstY=($dstY>($dstH/2))?floor($dstH/s):$dstY; 
$white = ImageColorAllocate($ni,255,255,255); 
$black = ImageColorAllocate($ni,0,0,0); 
imagefilledrectangle($ni,0,0,$dstW,$dstH,$white);// 填充背景色 
ImageCopyResized($ni,$im,$dstX,$dstY,0,0,$fdstW,$fdstH,$srcW,$srcH); 
if($markwords!=null) 
{ 
$markwords=iconv("gb2312","UTF-8",$markwords); 
//轉換文字編碼 
ImageTTFText($ni,20,30,450,560,$black,"simhei.ttf",$markwords); //寫入文字水印
//參數依次為,文字大小|偏轉度|橫坐標|縱坐標|文字顏色|文字類型|文字內容
} 
elseif($markimage!=null) 
{ 
$wimage_data = GetImageSize($markimage); 
switch($wimage_data[2]) 
{ 
case 1: 
$wimage=@ImageCreateFromGIF($markimage); 
break; 
case 2: 
$wimage=@ImageCreateFromJPEG($markimage); 
break; 
case 3: 
$wimage=@ImageCreateFromPNG($markimage); 
break; 
} 
image($ni,$wimage,500,560,0,0,88,31); //寫入圖片水印,水印圖片大小默認為88*31
imagedestroy($wimage); 
} 
ImageJpeg($ni,$dstFile,$rate); 
ImageJpeg($ni,$srcFile,$rate);
imagedestroy($im); 
imagedestroy($ni); 
} 
?>
