open($file); $frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds($sec)); $frame->save($thumbnail); return($thumbnail); } function getThumbnail(string $file, int $size) { list($width, $height) = getimagesize($file); // Create an Imagick object $imagick = new Imagick($file); // Function to set the background color $imagick->setbackgroundcolor('rgb(0, 0, 0)'); // Use thumbnailImage function $imagick->thumbnailImage($width*$size/$height, $size, true, true); header("Content-Type: image/jpg"); // Display the output image echo $imagick->getImageBlob(); } ?>