Last active
December 18, 2015 15:28
-
-
Save Djuki/5804506 to your computer and use it in GitHub Desktop.
Create youtube image with play button and scrubber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get image for video preview | |
* | |
* @param $videoId | |
* | |
* @return string | |
*/ | |
public function createVideoImage($videoId) | |
{ | |
$tempImage = $this->createVideoTempImage($videoId); | |
$mainImage = ImageWorkshop::initFromPath($tempImage); | |
$width = $mainImage->getWidth(); | |
$playButtonPath = Config::get('tools.video.play_button'); | |
$playImage = ImageWorkshop::initFromPath($playButtonPath); | |
$scrubberPath = Config::get('tools.video.scrubber'); | |
$scrubberImage = ImageWorkshop::initFromPath($scrubberPath); | |
$playImage->resizeInPixel($width, null, true); | |
$scrubberImage->resizeInPixel($width, null, true); | |
$mainImage->addLayer(2, $playImage); | |
$mainImage->addLayer(3, $scrubberImage, 0, 0 , 'LB'); | |
$mainImage->mergeAll(); | |
$imageName = md5($videoId).'.jpg'; | |
$mainImage->save($this->getImageSaveFolder(), $imageName, true, null, 100); | |
unlink($tempImage); | |
return $imageName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment