diff --git a/modules/file/file.admin.controller.php b/modules/file/file.admin.controller.php
index 96b18083c..a375e4645 100644
--- a/modules/file/file.admin.controller.php
+++ b/modules/file/file.admin.controller.php
@@ -74,7 +74,9 @@ class fileAdminController extends file
$config->image_autoconv['bmp2jpg'] = Context::get('image_autoconv_bmp2jpg') === 'Y' ? true : false;
$config->image_autoconv['png2jpg'] = Context::get('image_autoconv_png2jpg') === 'Y' ? true : false;
$config->image_autoconv['webp2jpg'] = Context::get('image_autoconv_webp2jpg') === 'Y' ? true : false;
+ $config->image_autoconv['gif2mp4'] = Context::get('image_autoconv_gif2mp4') === 'Y' ? true : false;
$config->image_autoconv_quality = max(50, min(100, intval(Context::get('image_autoconv_quality'))));
+ $config->ffmpeg_command = escape(utf8_trim(Context::get('ffmpeg_command'))) ?: '/usr/bin/ffmpeg';
$config->image_autorotate = Context::get('image_autorotate') === 'Y' ? true : false;
$config->image_autorotate_quality = max(50, min(100, intval(Context::get('image_autorotate_quality'))));
@@ -161,7 +163,9 @@ class fileAdminController extends file
$file_config->image_autoconv['bmp2jpg'] = Context::get('image_autoconv_bmp2jpg') === 'Y' ? true : false;
$file_config->image_autoconv['png2jpg'] = Context::get('image_autoconv_png2jpg') === 'Y' ? true : false;
$file_config->image_autoconv['webp2jpg'] = Context::get('image_autoconv_webp2jpg') === 'Y' ? true : false;
+ $file_config->image_autoconv['gif2mp4'] = Context::get('image_autoconv_gif2mp4') === 'Y' ? true : false;
$file_config->image_autoconv_quality = max(50, min(100, intval(Context::get('image_autoconv_quality'))));
+ $file_config->ffmpeg_command = escape(utf8_trim(Context::get('ffmpeg_command'))) ?: '/usr/bin/ffmpeg';
$file_config->image_autorotate = Context::get('image_autorotate') === 'Y' ? true : false;
$file_config->image_autorotate_quality = max(50, min(100, intval(Context::get('image_autorotate_quality'))));
diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php
index f2e96c6f1..cd46a13c6 100644
--- a/modules/file/file.controller.php
+++ b/modules/file/file.controller.php
@@ -1064,9 +1064,13 @@ class fileController extends file
{
$convert = array($image_width, $image_height, 'jpg', $config->image_autoconv_quality ?: 75, 0);
}
+ if($config->image_autoconv['gif2mp4'] && function_exists('exec') && $image_type === 1)
+ {
+ $convert = array($image_width, $image_height, 'mp4', $config->image_autoconv_quality ?: 75, 0);
+ }
// Check image rotation
- if($config->image_autorotate && function_exists('exif_read_data'))
+ if($config->image_autorotate && $image_type !== 1 && function_exists('exif_read_data'))
{
$exif = @exif_read_data($file_info['tmp_name']);
if($exif && isset($exif['Orientation']))
@@ -1154,11 +1158,26 @@ class fileController extends file
// Convert image if necessary
if ($convert)
{
- $result = FileHandler::createImageFile($file_info['tmp_name'], $file_info['tmp_name'] . '.conv', $convert[0], $convert[1], $convert[2], 'crop', $convert[3], $convert[4]);
+ if ($convert[2] === 'mp4')
+ {
+ $command = $config->ffmpeg_command ?: '/usr/bin/ffmpeg';
+ $command .= ' -i ' . escapeshellarg($file_info['tmp_name']);
+ $command .= ' -movflags faststart -pix_fmt yuv420p -c:v libx264 -crf 23 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"';
+ $command .= ' ' . escapeshellarg($file_info['tmp_name'] . '.mp4');
+ $status = @exec($command, $output, $return_var);
+ $result = $return_var == 0 ? true : false;
+ $newext = '.mp4';
+ }
+ else
+ {
+ $result = FileHandler::createImageFile($file_info['tmp_name'], $file_info['tmp_name'] . '.conv', $convert[0], $convert[1], $convert[2], 'crop', $convert[3], $convert[4]);
+ $newext = '.conv';
+ }
+
if ($result)
{
$file_info['name'] = preg_replace('/\.' . preg_quote($file_info['extension'], '/') . '$/i', '.' . $convert[2], $file_info['name']);
- $file_info['tmp_name'] = $file_info['tmp_name'] . '.conv';
+ $file_info['tmp_name'] = $file_info['tmp_name'] . $newext;
$file_info['size'] = filesize($file_info['tmp_name']);
$file_info['extension'] = $convert[2];
$file_info['converted'] = true;
diff --git a/modules/file/file.model.php b/modules/file/file.model.php
index 36b8c9d44..c68c0835c 100644
--- a/modules/file/file.model.php
+++ b/modules/file/file.model.php
@@ -202,6 +202,7 @@ class fileModel extends file
$config->image_autoconv_quality = $file_config->image_autoconv_quality;
$config->image_autorotate = $file_config->image_autorotate;
$config->image_autorotate_quality = $file_config->image_autorotate_quality;
+ $config->ffmpeg_command = $file_config->ffmpeg_command;
$config->download_grant = $file_config->download_grant;
$config->allow_outlink = $file_config->allow_outlink;
$config->allow_outlink_site = $file_config->allow_outlink_site;
@@ -226,6 +227,7 @@ class fileModel extends file
if(!$config->image_autoconv_quality) $config->image_autoconv_quality = $file_module_config->image_autoconv_quality;
if(!$config->image_autorotate) $config->image_autorotate = $file_module_config->image_autorotate;
if(!$config->image_autorotate_quality) $config->image_autorotate_quality = $file_module_config->image_autorotate_quality;
+ if(!$config->ffmpeg_command) $config->ffmpeg_command = $file_module_config->ffmpeg_command;
// Default setting if not exists
if(!$config->allowed_filesize) $config->allowed_filesize = '2';
diff --git a/modules/file/lang/en.php b/modules/file/lang/en.php
index 7aa77c4e6..b76c6a24a 100644
--- a/modules/file/lang/en.php
+++ b/modules/file/lang/en.php
@@ -27,6 +27,8 @@ $lang->image_autoconv = 'Auto-Convert Image';
$lang->image_autoconv_bmp2jpg = 'BMP → JPG';
$lang->image_autoconv_png2jpg = 'PNG → JPG';
$lang->image_autoconv_webp2jpg = 'WebP → JPG';
+$lang->image_autoconv_gif2mp4 = 'GIF → MP4';
+$lang->ffmpeg_path = 'Path to ffmpeg';
$lang->image_autorotate = 'Auto-Rotate Image';
$lang->inline_download_format = 'Open in current window';
$lang->inline_download_image = 'Image';
@@ -49,6 +51,7 @@ $lang->about_allowed_size_limits = 'The file size will be limited to the value s
$lang->about_allowed_filetypes = 'Rhymix no longer uses the old *.* syntax. Simply list the extensions you wish to allow.
Please use a comma (,) to separate items: e.g. doc, zip, pdf';
$lang->about_max_image_size = 'You can limit the maximum width and/or height of uploaded images.
This limit does not apply to files uploaded by the administrator.';
$lang->about_image_autoconv = 'Automatically convert types of images that often cause trouble or waste disk space into other types.
This also works for WebP images that incorrectly have the JPG extension.
If enabled, this feature also applies to images uploaded by the administrator.';
+$lang->about_image_autoconv_mp4 = 'Automatically convert animated GIF images into MP4 videos to save storage and bandwidth.
Videos may not play properly in older browsers.';
$lang->about_image_autorotate = 'Automatically correct images that are rotated by mobile devices.
If enabled, this feature also applies to images uploaded by the administrator.';
$lang->cmd_delete_checked_file = 'Delete Selected Item(s)';
$lang->cmd_move_to_document = 'Move to Document';
diff --git a/modules/file/lang/ko.php b/modules/file/lang/ko.php
index bfceb93f6..1b407f3a5 100644
--- a/modules/file/lang/ko.php
+++ b/modules/file/lang/ko.php
@@ -27,6 +27,8 @@ $lang->image_autoconv = '이미지 자동 변환';
$lang->image_autoconv_bmp2jpg = 'BMP → JPG';
$lang->image_autoconv_png2jpg = 'PNG → JPG';
$lang->image_autoconv_webp2jpg = 'WebP → JPG';
+$lang->image_autoconv_gif2mp4 = 'GIF → MP4';
+$lang->ffmpeg_path = 'ffmpeg 경로';
$lang->image_autorotate = '이미지 자동 회전';
$lang->inline_download_format = '다운로드시 현재 창 사용';
$lang->inline_download_image = '이미지';
@@ -49,6 +51,7 @@ $lang->about_allowed_size_limits = 'IE9 이하, 구버전 안드로이드 등에
$lang->about_allowed_filetypes = '업로드를 허용할 확장자 목록입니다. 구 버전의 *.* 문법은 사용하지 않습니다.
여러 개 입력시 쉼표(,)을 이용해서 구분해 주세요. 예) doc, zip, pdf';
$lang->about_max_image_size = '이미지 파일의 가로, 세로, 또는 가로세로 크기를 모두 제한할 수 있습니다.
관리자가 업로드한 파일에는 적용되지 않습니다.';
$lang->about_image_autoconv = '종종 문제를 일으키거나 용량을 낭비하는 이미지 타입을 다른 타입으로 자동 변환합니다.
WebP 이미지에 JPG 확장자가 잘못 부여된 경우에도 변환할 수 있습니다.
관리자가 업로드한 파일에도 적용됩니다.';
+$lang->about_image_autoconv_mp4 = '움직이는 GIF 이미지를 MP4 동영상으로 변환하여 용량 및 트래픽을 절약합니다.
구형 브라우저에서는 동영상이 재생되지 않을 수도 있습니다.';
$lang->about_image_autorotate = '모바일 기기 등에서 잘못 회전된 이미지를 바로잡습니다.
관리자가 업로드한 파일에도 적용됩니다.';
$lang->cmd_delete_checked_file = '선택항목 삭제';
$lang->cmd_move_to_document = '문서로 이동';
diff --git a/modules/file/tpl/file_module_config.html b/modules/file/tpl/file_module_config.html
index 2e167aaf8..815394b6b 100644
--- a/modules/file/tpl/file_module_config.html
+++ b/modules/file/tpl/file_module_config.html
@@ -81,7 +81,13 @@
-
{$lang->about_image_autoconv}
+{$lang->about_image_autoconv}
+ + +{$lang->about_image_autoconv_mp4}
{$lang->about_image_autoconv}
+{$lang->about_image_autoconv}
+ + +{$lang->about_image_autoconv_mp4}