logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://anongit.hacktivis.me/git/pleroma-fe.git/
commit: cd46f324d2057df4185c0df691766b9054b3dc46
parent ec11bdfc2b5239e59a6b7dbe4f474fda19260106
Author: HJ <30-hj@users.noreply.git.pleroma.social>
Date:   Thu, 30 Jan 2025 10:08:58 +0000

Merge branch '1354-image-compression-jpeg' into 'develop'

MediaUpload, Settings: Add option to always convert to jpeg.

Closes #1354

See merge request pleroma/pleroma-fe!2019

Diffstat:

Achangelog.d/always-jpeg.add2++
Msrc/components/media_upload/media_upload.js6+++---
Msrc/components/settings_modal/tabs/general_tab.vue8++++++++
Msrc/i18n/en.json1+
Msrc/modules/config.js3++-
5 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/changelog.d/always-jpeg.add 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 @@ -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 @@ -271,6 +271,14 @@ </li> <li> <BooleanSetting + path="alwaysUseJpeg" + expert="1" + > + {{ $t('settings.always_use_jpeg') }} + </BooleanSetting> + </li> + <li> + <BooleanSetting path="useContainFit" expert="1" > diff --git 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 @@ -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