當前位置:首頁 » 編程語言 » php動圖

php動圖

發布時間: 2025-02-10 17:01:10

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);
}
?>

熱點內容
電視父母鎖屏密碼應該會是什麼 發布:2025-02-11 08:36:42 瀏覽:891
梅花適合用哪些植物進行配置 發布:2025-02-11 08:30:54 瀏覽:251
安卓手機如何像蘋果一樣彈窗 發布:2025-02-11 08:26:33 瀏覽:911
壓縮文件掃碼 發布:2025-02-11 08:20:55 瀏覽:257
小米5安卓70怎麼分屏 發布:2025-02-11 08:00:58 瀏覽:139
訪問二維碼 發布:2025-02-11 08:00:11 瀏覽:882
騰訊雲香港伺服器搭建 發布:2025-02-11 07:53:44 瀏覽:793
eclipsejava編譯器 發布:2025-02-11 07:53:09 瀏覽:494
生化危機7D加密破解 發布:2025-02-11 07:48:32 瀏覽:943
資料庫新增資料庫 發布:2025-02-11 07:40:45 瀏覽:198