コード例 #1
0
 /**
  * validateThumbAndMediaInfo validate and manipulate a thumbnail params according to the given media info
  * 
  * @param thumbParams $thumbParams
  * @param mediaInfo $mediaInfo
  * @param string $errDescription
  * @return thumbParamsOutput or null for fail
  */
 protected static function validateThumbAndMediaInfo(thumbParams $thumbParams, mediaInfo $mediaInfo = null, &$errDescription)
 {
     $thumbParamsOutput = new thumbParamsOutput();
     $thumbParamsOutput->setFlavorParamsId($thumbParams->getId());
     $thumbParamsOutput->setFlavorParamsVersion($thumbParams->getVersion());
     $thumbParamsOutput->setName($thumbParams->getName());
     $thumbParamsOutput->setTags($thumbParams->getTags());
     $thumbParamsOutput->setDescription($thumbParams->getDescription());
     $thumbParamsOutput->setReadyBehavior($thumbParams->getReadyBehavior());
     $thumbParamsOutput->setFormat($thumbParams->getFormat());
     $thumbParamsOutput->setWidth($thumbParams->getWidth());
     $thumbParamsOutput->setHeight($thumbParams->getHeight());
     $thumbParamsOutput->setConversionEngines($thumbParams->getConversionEngines());
     $thumbParamsOutput->setConversionEnginesExtraParams($thumbParams->getConversionEnginesExtraParams());
     $thumbParamsOutput->setOperators($thumbParams->getOperators());
     $thumbParamsOutput->setEngineVersion($thumbParams->getEngineVersion());
     $thumbParamsOutput->setFileExt('jpg');
     $thumbParamsOutput->setCropType($thumbParams->getCropType());
     $thumbParamsOutput->setQuality($thumbParams->getQuality());
     $thumbParamsOutput->setCropX($thumbParams->getCropX());
     $thumbParamsOutput->setCropY($thumbParams->getCropY());
     $thumbParamsOutput->setCropWidth($thumbParams->getCropWidth());
     $thumbParamsOutput->setCropHeight($thumbParams->getCropHeight());
     $thumbParamsOutput->setCropProvider($thumbParams->getCropProvider());
     $thumbParamsOutput->setCropProviderData($thumbParams->getCropProviderData());
     $thumbParamsOutput->setVideoOffset($thumbParams->getVideoOffset());
     $thumbParamsOutput->setWidth($thumbParams->getWidth());
     $thumbParamsOutput->setHeight($thumbParams->getHeight());
     $thumbParamsOutput->setScaleWidth($thumbParams->getScaleWidth());
     $thumbParamsOutput->setScaleHeight($thumbParams->getScaleHeight());
     $thumbParamsOutput->setBackgroundColor($thumbParams->getBackgroundColor());
     if ($mediaInfo) {
         if ($thumbParamsOutput->getVideoOffset() && $mediaInfo->getVideoDuration()) {
             $videoDurationSec = floor($mediaInfo->getVideoDuration() / 1000);
             if ($thumbParamsOutput->getVideoOffset() > $videoDurationSec) {
                 $thumbParamsOutput->setVideoOffset($videoDurationSec);
             }
         }
     }
     return $thumbParamsOutput;
 }
コード例 #2
0
 /**
  * validateThumbAndMediaInfo validate and manipulate a thumbnail params according to the given media info
  *
  * @param thumbParams $thumbParams
  * @param mediaInfo $mediaInfo
  * @param string $errDescription
  * @return thumbParamsOutput or null for fail
  */
 protected static function validateThumbAndMediaInfo(thumbParams $thumbParams, mediaInfo $mediaInfo = null, &$errDescription, $srcAsset = null)
 {
     $thumbParamsOutput = new thumbParamsOutput();
     $thumbParamsOutput->setFlavorParamsId($thumbParams->getId());
     $thumbParamsOutput->setFlavorParamsVersion($thumbParams->getVersion());
     $thumbParamsOutput->setName($thumbParams->getName());
     $thumbParamsOutput->setTags($thumbParams->getTags());
     $thumbParamsOutput->setDescription($thumbParams->getDescription());
     $thumbParamsOutput->setReadyBehavior($thumbParams->getReadyBehavior());
     $thumbParamsOutput->setFormat($thumbParams->getFormat());
     $thumbParamsOutput->setWidth($thumbParams->getWidth());
     $thumbParamsOutput->setHeight($thumbParams->getHeight());
     $thumbParamsOutput->setConversionEngines($thumbParams->getConversionEngines());
     $thumbParamsOutput->setConversionEnginesExtraParams($thumbParams->getConversionEnginesExtraParams());
     $thumbParamsOutput->setOperators($thumbParams->getOperators());
     $thumbParamsOutput->setEngineVersion($thumbParams->getEngineVersion());
     $extensionTypes = kConf::hasParam('image_file_ext') ? kConf::get('image_file_ext') : array();
     $ext = null;
     if ($srcAsset) {
         $ext = $srcAsset->getFileExt();
     }
     if (!is_null($ext) && in_array($ext, $extensionTypes)) {
         $thumbParamsOutput->setFileExt($ext);
     } else {
         $thumbParamsOutput->setFileExt('jpg');
     }
     $thumbParamsOutput->setRotate($mediaInfo ? $mediaInfo->getVideoRotation() : null);
     $thumbParamsOutput->setCropType($thumbParams->getCropType());
     $thumbParamsOutput->setQuality($thumbParams->getQuality());
     $thumbParamsOutput->setCropX($thumbParams->getCropX());
     $thumbParamsOutput->setCropY($thumbParams->getCropY());
     $thumbParamsOutput->setCropWidth($thumbParams->getCropWidth());
     $thumbParamsOutput->setCropHeight($thumbParams->getCropHeight());
     $thumbParamsOutput->setCropProvider($thumbParams->getCropProvider());
     $thumbParamsOutput->setCropProviderData($thumbParams->getCropProviderData());
     $thumbParamsOutput->setVideoOffset($thumbParams->getVideoOffset());
     $thumbParamsOutput->setWidth($thumbParams->getWidth());
     $thumbParamsOutput->setHeight($thumbParams->getHeight());
     $thumbParamsOutput->setScaleWidth($thumbParams->getScaleWidth());
     $thumbParamsOutput->setScaleHeight($thumbParams->getScaleHeight());
     $thumbParamsOutput->setBackgroundColor($thumbParams->getBackgroundColor());
     if ($mediaInfo && $mediaInfo->getVideoDuration()) {
         $videoDurationSec = floor($mediaInfo->getVideoDuration() / 1000);
         if ($thumbParamsOutput->getVideoOffset()) {
             if ($thumbParamsOutput->getVideoOffset() > $videoDurationSec) {
                 $thumbParamsOutput->setVideoOffset($videoDurationSec);
             }
         } elseif (!is_null($thumbParams->getVideoOffsetInPercentage())) {
             $percentage = $thumbParams->getVideoOffsetInPercentage() / 100;
             $thumbParamsOutput->setVideoOffset(floor($videoDurationSec * $percentage));
         }
     }
     return $thumbParamsOutput;
 }