PHP code example of jyggen / youtubethumb

1. Go to this page and download the library: Download jyggen/youtubethumb library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jyggen / youtubethumb example snippets


use jyggen\Youtube\Thumbnail;

// Load a thumbnail and save it to disk.
Thumbnail::forge('83fJ7hlZkpA')->save('my_path/');

// Maybe we wanna do some changes aswell. Retrieve the previously forged instance.
$thumb = Thumbnail::instance('83fJ7hlZkpA');

// Get the Thumbnail's GD resource.
$data  = $thumb->getData();

// Create a new GD resource and copy a portion of the thumbnail into our new image.
$dest = imagecreatetruecolor(80, 40);
imagecopy($dest, $data, 0, 0, 20, 13, 80, 40);

// Set our old thumbnail to the new resized one.
$thumb->setData($dest);

// Oh shit, did we fudge up something? Reset the image to its original state.
$thumb->reset();

// We want to save the image again, but with a different name and extension.
$thumb->setName('my_awesome_thumbnail');
$thumb->save('my_path/', 'gif');