diff --git a/changelog.d/always-jpeg.add b/changelog.d/always-jpeg.add new file mode 100644 index 0000000000000000000000000000000000000000..f29ffeec48796fd94bcea09b263db4d9b2216cd5 --- /dev/null +++ b/changelog.d/always-jpeg.add @@ -0,0 +1 @@ +Added option to always convert images to JPEG format instead of using WebP when compressing images. \ No newline at end of file diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js index f0fd0155f2a27a55d13de70ce27d840c0974e29b..f2cbfc405affa4d95db578b4ce7640a883bd445a 100644 --- a/src/components/media_upload/media_upload.js +++ b/src/components/media_upload/media_upload.js @@ -76,9 +76,9 @@ const mediaUpload = { const testCanvas = document.createElement('canvas') const supportsWebP = testCanvas.toDataURL('image/webp').startsWith('data:image/webp') - // Convert to WebP if supported, otherwise JPEG - const type = supportsWebP ? 'image/webp' : 'image/jpeg' - const extension = supportsWebP ? '.webp' : '.jpg' + // Convert to WebP if supported and alwaysUseJpeg is false, otherwise JPEG + const type = (!this.$store.getters.mergedConfig.alwaysUseJpeg && supportsWebP) ? 'image/webp' : 'image/jpeg' + const extension = type === 'image/webp' ? '.webp' : '.jpg' // Remove the original extension and add new one const newFileName = file.name.replace(/\.[^/.]+$/, '') + extension diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue index 6d01f208e449be4526422a5b1efb236c7e6b8e3a..9d23630a99805bc1d293854128fba0250dc199d7 100644 --- a/src/components/settings_modal/tabs/general_tab.vue +++ b/src/components/settings_modal/tabs/general_tab.vue @@ -269,6 +269,14 @@ {{ $t('settings.image_compression') }} </BooleanSetting> </li> + <li> + <BooleanSetting + path="alwaysUseJpeg" + expert="1" + > + {{ $t('settings.always_use_jpeg') }} + </BooleanSetting> + </li> <li> <BooleanSetting path="useContainFit" diff --git a/src/i18n/en.json b/src/i18n/en.json index 3fad5ca831175e16b828a52734bbc4e58d6856fa..ad81830f9df06960b3c332dcd883613607921962 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -440,6 +440,7 @@ "attachmentRadius": "Attachments", "attachments": "Attachments", "image_compression": "Compress images before uploading", + "always_use_jpeg": "Always convert images to JPEG format", "avatar": "Avatar", "avatarAltRadius": "Avatars (notifications)", "avatarRadius": "Avatars", diff --git a/src/modules/config.js b/src/modules/config.js index ebc8b9311ec8e8de6f9e2811d57c55c895822816..0bfe3b1e842e84e2b324f69f950a2b16b01783c6 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -194,7 +194,8 @@ export const defaultState = { useAbsoluteTimeFormat: undefined, // instance default absoluteTimeFormatMinAge: undefined, // instance default absoluteTime12h: undefined, // instance default - imageCompression: true + imageCompression: true, + alwaysUseJpeg: false } // caching the instance default properties