Файл: vsime.com/system/functions/create_screen.php
Строк: 87
<?
    function create_screen($file, $path=NULL, $w=48, $h=48, $dop=NULL, $need_name=NULL, $show=0, $prover=0)
    {
        if (is_file($file))
        {
            @$movie = new ffmpeg_movie($file);
            if($imgc = @imagecreatefromstring(file_get_contents($file)))
            {
                $img_x=imagesx($imgc);
                $img_y=imagesy($imgc);
                if ($img_x==$img_y)
                {
                    $dstW=$w; // ширина
                    $dstH=$h; // высота 
                } elseif ($img_x>$img_y) {
                    $prop=$img_x/$img_y;
                    $dstW=$w;
                    $dstH=ceil($dstW/$prop);
                } else {
                    $prop=$img_y/$img_x;
                    $dstH=$h;
                    $dstW=ceil($dstH/$prop);
                }
                if ($img_x < $dstW)$dstW = $img_x;
                if ($img_y < $dstH)$dstH = $img_y;
                /*if ($img_x > $w || $img_y > $h)
                {
                    $new_w = ceil($img_x - $w)/2;
                    $new_h = ceil($img_y - $h)/2;
                    $newImage = imagecreatetruecolor($dstW, $dstH);
                    imagecopyresampled($newImage, $imgc, 0, 0,  $new_w, $new_h, $w, $h, $w, $h);
                    $screen = $newImage;
                    $pix_one = $new_w;
                    $pix_two = $new_w + $w;
                    //echo "<script>alert('от $pix_one до $pix_two');</script>n";
                } else {*/
                $screen = imagecreatetruecolor($dstW, $dstH);
                imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
                //}
                imagedestroy($imgc);
                if ($show == 0)
                {
                    if ($need_name==NULL)$name = $w."-".$h."_".$dop."screen.png";
                    else $name = $need_name;
                    if ($prover == 0)imagepng($screen, $path.$name);
                }
                else
                {
                    header("Content-type: image/png");
                    imagepng($screen);
                }
                imagedestroy($screen);
            }
            /*elseif(@$image_id3)
            {
                $imgc = @imagecreatefromstring($image_id3);
                $img_x=imagesx($imgc);
                $img_y=imagesy($imgc);
                if ($img_x==$img_y)
                {
                    $dstW=$w; // ширина
                    $dstH=$h; // высота 
                } elseif ($img_x>$img_y) {
                    $prop=$img_x/$img_y;
                    $dstW=$w;
                    $dstH=ceil($dstW/$prop);
                } else {
                    $prop=$img_y/$img_x;
                    $dstH=$h;
                    $dstW=ceil($dstH/$prop);
                }
                if ($img_x < $dstW)$dstW = $img_x;
                if ($img_y < $dstH)$dstH = $img_y;
                $screen = imagecreatetruecolor($dstW, $dstH);
                imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
                //}
                imagedestroy($imgc);
                if ($show == 0)
                {
                    if ($need_name == NULL)$name = $w."-".$h."_".$dop."screen.png";
                    else $name = $need_name;
                    if ($prover == 0)imagepng($screen, $path.$name);
                }
                else
                {
                    header("Content-type: image/png");
                    imagepng($screen);
                }
            }*/
            elseif($movie)
            {
                $k_frames = $movie -> getFrameCount(); //к-тво кадров
                for($kp=1; $kp<=60; $kp++) //выбираем случайный кадр
                {
                    $image = @$movie -> getFrame($kp);
                    if ($image)$show_img = $image -> toGDImage(); //если кадр в нормальном состоянии, то выбираем его для дальнейшей работы
                }
                if(isset($show_img) && $show_img)
                {
                    $imgc = $show_img;
                    $img_x = imagesx($imgc);
                    $img_y = imagesy($imgc);
                    if ($img_x == $img_y)
                    {
                        $dstW = $w; // ширина
                        $dstH = $h; // высота 
                    }
                    elseif ($img_x > $img_y)
                    {
                        $prop = $img_x/$img_y;
                        $dstW = $w;
                        $dstH = ceil($dstW/$prop);
                    }
                    else
                    {
                        $prop = $img_y/$img_x;
                        $dstH = $h;
                        $dstW = ceil($dstH/$prop);
                    }
                    if ($img_x < $dstW)$dstW = $img_x;
                    if ($img_y < $dstH)$dstH = $img_y;
                    $screen=imagecreatetruecolor($dstW, $dstH);
                    imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
                    imagedestroy($imgc);
                    if ($show == 0)
                    {
                        if ($need_name == NULL)$name = $w."-".$h."_".$dop."screen.png";
                        else $name = $need_name;
                        if ($prover == 0)imagepng($screen, $path.$name);
                    }
                    else
                    {
                        header("Content-type: image/png");
                        imagepng($screen);
                    }
                    imagedestroy($screen);
                }
            }
            else $name = NULL;
        } else $name = NULL;
        if (!isset($name))$name = NULL;
        if ($show == 0)return $name;
    }
?>