Add option to always reencode images #2601

This commit is contained in:
Kijin Sung 2025-10-25 12:36:18 +09:00
parent e676949669
commit 2a9b336988
5 changed files with 25 additions and 0 deletions

View file

@ -92,6 +92,7 @@ class FileAdminController extends File
$config->image_quality_adjustment = max(50, min(100, intval(Context::get('image_quality_adjustment')))); $config->image_quality_adjustment = max(50, min(100, intval(Context::get('image_quality_adjustment'))));
$config->image_autorotate = Context::get('image_autorotate') === 'Y' ? true : false; $config->image_autorotate = Context::get('image_autorotate') === 'Y' ? true : false;
$config->image_remove_exif_data = Context::get('image_remove_exif_data') === 'Y' ? true : false; $config->image_remove_exif_data = Context::get('image_remove_exif_data') === 'Y' ? true : false;
$config->image_always_reencode = Context::get('image_always_reencode') === 'Y' ? true : false;
// Video settings // Video settings
$config->max_video_width = intval(Context::get('max_video_width')) ?: ''; $config->max_video_width = intval(Context::get('max_video_width')) ?: '';

View file

@ -1290,6 +1290,12 @@ class FileController extends File
} }
} }
// Check if this image should be reencoded anyway
if (isset($config->image_always_reencode) && $config->image_always_reencode)
{
$force = true;
}
// Convert image if adjusted // Convert image if adjusted
if ($adjusted['width'] !== $image_info['width'] || if ($adjusted['width'] !== $image_info['width'] ||
$adjusted['height'] !== $image_info['height'] || $adjusted['height'] !== $image_info['height'] ||

View file

@ -107,6 +107,8 @@ $lang->image_autorotate = 'Fix Image Rotation';
$lang->about_image_autorotate = 'correct images that are rotated by mobile devices.'; $lang->about_image_autorotate = 'correct images that are rotated by mobile devices.';
$lang->image_remove_exif_data = 'Remove EXIF'; $lang->image_remove_exif_data = 'Remove EXIF';
$lang->about_image_remove_exif_data = 'remove EXIF data including camera, GPS information, and more in image file for privacy.<br />Even if this option is not used, EXIF data may be removed when the image is converted by other settings.'; $lang->about_image_remove_exif_data = 'remove EXIF data including camera, GPS information, and more in image file for privacy.<br />Even if this option is not used, EXIF data may be removed when the image is converted by other settings.';
$lang->image_always_reencode = 'Always Reencode';
$lang->about_image_always_reencode = 'Reencode images to a constant quality even if they do not meet one of the conditions above. This may help save disk space and traffic.';
$lang->image_autoconv_gif2mp4 = 'Convert GIF to MP4'; $lang->image_autoconv_gif2mp4 = 'Convert GIF to MP4';
$lang->about_image_autoconv_gif2mp4 = 'convert animated GIF images into MP4 videos to save storage and bandwidth.<br />This requires ffmpeg settings below. Videos may not play properly in older browsers.'; $lang->about_image_autoconv_gif2mp4 = 'convert animated GIF images into MP4 videos to save storage and bandwidth.<br />This requires ffmpeg settings below. Videos may not play properly in older browsers.';
$lang->max_video_size = 'Limit Video Size'; $lang->max_video_size = 'Limit Video Size';

View file

@ -107,6 +107,8 @@ $lang->image_autorotate = '이미지 회전 수정';
$lang->about_image_autorotate = '모바일 기기 등에서 잘못 회전된 이미지를 바로잡습니다.'; $lang->about_image_autorotate = '모바일 기기 등에서 잘못 회전된 이미지를 바로잡습니다.';
$lang->image_remove_exif_data = 'EXIF 제거'; $lang->image_remove_exif_data = 'EXIF 제거';
$lang->about_image_remove_exif_data = '프라이버시를 위해 이미지 파일에서 카메라, GPS 정보 등이 포함되어 있는 EXIF 데이터를 삭제합니다.<br />이 옵션을 사용하지 않아도 다른 설정에 의해 이미지가 변환될 경우에도 EXIF 데이터가 삭제될 수 있습니다.'; $lang->about_image_remove_exif_data = '프라이버시를 위해 이미지 파일에서 카메라, GPS 정보 등이 포함되어 있는 EXIF 데이터를 삭제합니다.<br />이 옵션을 사용하지 않아도 다른 설정에 의해 이미지가 변환될 경우에도 EXIF 데이터가 삭제될 수 있습니다.';
$lang->image_always_reencode = '무조건 재인코딩';
$lang->about_image_always_reencode = '위에서 설정한 조건에 해당되지 않더라도 무조건 일정한 화질로 재인코딩하여 용량과 트래픽을 절약합니다.';
$lang->image_autoconv_gif2mp4 = 'GIF → MP4 변환'; $lang->image_autoconv_gif2mp4 = 'GIF → MP4 변환';
$lang->about_image_autoconv_gif2mp4 = '움직이는 GIF 이미지를 MP4 동영상으로 변환하여 용량 및 트래픽을 절약합니다.<br />아래에서 ffmpeg 설정을 해야 하며, 구형 브라우저에서는 동영상이 재생되지 않을 수도 있습니다.'; $lang->about_image_autoconv_gif2mp4 = '움직이는 GIF 이미지를 MP4 동영상으로 변환하여 용량 및 트래픽을 절약합니다.<br />아래에서 ffmpeg 설정을 해야 하며, 구형 브라우저에서는 동영상이 재생되지 않을 수도 있습니다.';
$lang->max_video_size = '동영상 크기 제한'; $lang->max_video_size = '동영상 크기 제한';

View file

@ -129,6 +129,20 @@
<p class="x_text-info" cond="!function_exists('exif_read_data')">{$lang->msg_cannot_use_exif}</p> <p class="x_text-info" cond="!function_exists('exif_read_data')">{$lang->msg_cannot_use_exif}</p>
</div> </div>
</div> </div>
<div class="x_control-group">
<label class="x_control-label">{$lang->image_always_reencode}</label>
<div class="x_controls">
<label for="image_always_reencode_Y" class="x_inline">
<input type="radio" name="image_always_reencode" id="image_always_reencode_Y" value="Y" checked="checked"|cond="$config->image_always_reencode === true" />
{$lang->cmd_yes}
</label>
<label for="image_always_reencode_N" class="x_inline">
<input type="radio" name="image_always_reencode" id="image_always_reencode_N" value="N" checked="checked"|cond="$config->image_always_reencode !== true" />
{$lang->cmd_no}
</label>
<p class="x_help-block">{$lang->about_image_always_reencode}</p>
</div>
</div>
<div class="x_control-group"> <div class="x_control-group">
<label class="x_control-label">{$lang->image_autoconv_gif2mp4}</label> <label class="x_control-label">{$lang->image_autoconv_gif2mp4}</label>
<div class="x_controls"> <div class="x_controls">