Change the resize, it now depends of the format
This commit is contained in:
		
					parent
					
						
							
								b1e6eeaf95
							
						
					
				
			
			
				commit
				
					
						68852ca65a
					
				
			
		
					 2 changed files with 33 additions and 54 deletions
				
			
		|  | @ -219,16 +219,7 @@ class FFMpeg extends Binary | |||
| 
 | ||||
|         $cmd_part2 = ''; | ||||
| 
 | ||||
|         if ($format->getWidth() && $format->getHeight()) { | ||||
| 
 | ||||
|             switch ($format->getResizeMode()) { | ||||
|                 case Video::RESIZEMODE_FIT: | ||||
|                 default: | ||||
|                     $width = $this->getMultiple($format->getWidth(), 16); | ||||
|                     $height = $this->getMultiple($format->getHeight(), 16); | ||||
|                     break; | ||||
|                 case Video::RESIZEMODE_INSET: | ||||
| 
 | ||||
|         if ($format instanceof Format\ResizableVideo) { | ||||
|             if ( ! $this->prober) { | ||||
|                 throw new LogicException('You must set a valid prober if you use RESIZEMODE_INSET'); | ||||
|             } | ||||
|  | @ -251,22 +242,10 @@ class FFMpeg extends Binary | |||
|                 } | ||||
|             } | ||||
| 
 | ||||
|                     $originalRatio = $originalWidth / $originalHeight; | ||||
|             list($width, $height) = $format->getComputedDimensions($originalWidth, $originalHeight); | ||||
| 
 | ||||
|                     $targetRatio = $format->getWidth() / $format->getHeight(); | ||||
|                      | ||||
|                     if($targetRatio >= $originalRatio){ | ||||
|                         $height = $format->getHeight(); | ||||
|                         $width = $format->getHeight() * $originalRatio; | ||||
|                     }else{ | ||||
|                         $width = $format->getWidth(); | ||||
|                         $height = $format->getWidth() / $originalRatio; | ||||
|                     } | ||||
| 
 | ||||
|                     $width = $this->getMultiple($width, 16); | ||||
|                     $height = $this->getMultiple($height, 16); | ||||
|                     break; | ||||
|             } | ||||
|             $width = $this->getMultiple($format->getWidth(), 16); | ||||
|             $height = $this->getMultiple($format->getHeight(), 16); | ||||
| 
 | ||||
|             $cmd_part2 .= ' -s ' . $width . 'x' . $height; | ||||
|         } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue