From 77607e0c024c27b278eaa1869cb1d16b9089d135 Mon Sep 17 00:00:00 2001 From: Daku Date: Fri, 23 May 2014 23:28:56 +0100 Subject: [PATCH] keep aspect ratio when created video thumbnail --- core/basethemelet.class.php | 2 +- ext/handle_video/main.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/basethemelet.class.php b/core/basethemelet.class.php index 3d62d3da..6f189552 100644 --- a/core/basethemelet.class.php +++ b/core/basethemelet.class.php @@ -56,7 +56,7 @@ class BaseThemelet { $h_tip = html_escape($image->get_tooltip()); $h_tags = strtolower($image->get_tag_list()); - $extArr = array_flip(array('swf', 'svg', 'mp4', 'ogv', 'webm', 'flv')); //List of thumbless filetypes + $extArr = array_flip(array('swf', 'svg')); //List of thumbless filetypes if(!isset($extArr[$image->ext])){ $tsize = get_thumbnail_size($image->width, $image->height); }else{ diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index d9d0cfd3..781a9220 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -70,7 +70,8 @@ class VideoFileHandler extends DataHandlerExtension { $inname = escapeshellarg(warehouse_path("images", $hash)); $outname = escapeshellarg(warehouse_path("thumbs", $hash)); - $cmd = escapeshellcmd("{$ffmpeg} -i {$inname} -s {$w}x{$h} -ss 00:00:00.0 -f image2 -vframes 1 {$outname}"); + $cmd = escapeshellcmd("{$ffmpeg} -i {$inname} -vf scale='if(gt(a,{$w}/{$h}),{$w},-1)':'if(gt(a,{$w}/{$h}),-1,{$h})' -ss 00:00:00.0 -f image2 -vframes 1 {$outname}"); + exec($cmd, $output, $ret); // TODO: We should really check the result of the exec to see if it really succeeded.