mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-11 09:59:59 +08:00
✨ Feature(custom): support specific format option for image conversion
ISSUES CLOSED: #124
This commit is contained in:
@@ -1472,6 +1472,17 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-show="compressForm.isConvert"
|
||||
:label="$T('UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT_SPECIFIC')"
|
||||
>
|
||||
<el-input
|
||||
v-model="compressForm.formatConvertObj"
|
||||
placeholder="{"jpg": "png", "png": "jpg"}"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 4}"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP')"
|
||||
>
|
||||
@@ -1664,6 +1675,8 @@ const waterMarkPositionMap = new Map([
|
||||
['centre', $T('UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER')]
|
||||
])
|
||||
|
||||
const imageExtList = ['jpg', 'jpeg', 'png', 'webp', 'bmp', 'tiff', 'tif', 'svg', 'ico', 'avif', 'heif', 'heic']
|
||||
|
||||
const availableFormat = ['avif', 'dz', 'fits', 'gif', 'heif', 'input', 'jpeg', 'jpg', 'jp2', 'jxl', 'magick', 'openslide', 'pdf', 'png', 'ppm', 'raw', 'svg', 'tiff', 'tif', 'v', 'webp']
|
||||
|
||||
const waterMarkForm = reactive<any>({
|
||||
@@ -1686,13 +1699,15 @@ const compressForm = reactive<any>({
|
||||
isReSize: false,
|
||||
reSizeWidth: 500,
|
||||
reSizeHeight: 500,
|
||||
skipReSizeOfSmallImg: false,
|
||||
isReSizeByPercent: false,
|
||||
reSizePercent: 50,
|
||||
isRotate: false,
|
||||
rotateDegree: 0,
|
||||
isRemoveExif: false,
|
||||
isFlip: false,
|
||||
isFlop: false
|
||||
isFlop: false,
|
||||
formatConvertObj: '{}'
|
||||
})
|
||||
|
||||
function closeDialog () {
|
||||
@@ -1700,6 +1715,17 @@ function closeDialog () {
|
||||
}
|
||||
|
||||
function handleSaveConfig () {
|
||||
let formatConvertObj = {}
|
||||
try {
|
||||
formatConvertObj = JSON.parse(compressForm.formatConvertObj)
|
||||
} catch (error) {
|
||||
}
|
||||
const formatConvertObjEntries = Object.entries(formatConvertObj)
|
||||
const formatConvertObjEntriesFilter = formatConvertObjEntries.filter((item: any) => {
|
||||
return imageExtList.includes(item[0]) && availableFormat.includes(item[1])
|
||||
})
|
||||
const formatConvertObjFilter = Object.fromEntries(formatConvertObjEntriesFilter)
|
||||
compressForm.formatConvertObj = formatConvertObjFilter
|
||||
saveConfig('buildIn.compress', toRaw(compressForm))
|
||||
saveConfig('buildIn.watermark', toRaw(waterMarkForm))
|
||||
closeDialog()
|
||||
@@ -1723,6 +1749,11 @@ async function initForm () {
|
||||
compressForm.isRemoveExif = compress.isRemoveExif ?? false
|
||||
compressForm.isFlip = compress.isFlip ?? false
|
||||
compressForm.isFlop = compress.isFlop ?? false
|
||||
try {
|
||||
compressForm.formatConvertObj = JSON.stringify(compress.formatConvertObj ?? {})
|
||||
} catch (error) {
|
||||
compressForm.formatConvertObj = '{}'
|
||||
}
|
||||
}
|
||||
if (watermark) {
|
||||
waterMarkForm.isAddWatermark = watermark.isAddWatermark ?? false
|
||||
|
||||
@@ -303,6 +303,17 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-show="compressForm.isConvert"
|
||||
:label="$T('UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT_SPECIFIC')"
|
||||
>
|
||||
<el-input
|
||||
v-model="compressForm.formatConvertObj"
|
||||
placeholder="{"jpg": "png", "png": "jpg"}"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 4}"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP')"
|
||||
>
|
||||
@@ -474,6 +485,8 @@ const waterMarkPositionMap = new Map([
|
||||
['centre', $T('UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER')]
|
||||
])
|
||||
|
||||
const imageExtList = ['jpg', 'jpeg', 'png', 'webp', 'bmp', 'tiff', 'tif', 'svg', 'ico', 'avif', 'heif', 'heic']
|
||||
|
||||
const availableFormat = ['avif', 'dz', 'fits', 'gif', 'heif', 'input', 'jpeg', 'jpg', 'jp2', 'jxl', 'magick', 'openslide', 'pdf', 'png', 'ppm', 'raw', 'svg', 'tiff', 'tif', 'v', 'webp']
|
||||
|
||||
const waterMarkForm = reactive<any>({
|
||||
@@ -503,7 +516,8 @@ const compressForm = reactive<any>({
|
||||
rotateDegree: 0,
|
||||
isRemoveExif: false,
|
||||
isFlip: false,
|
||||
isFlop: false
|
||||
isFlop: false,
|
||||
formatConvertObj: '{}'
|
||||
})
|
||||
|
||||
function closeDialog () {
|
||||
@@ -511,6 +525,17 @@ function closeDialog () {
|
||||
}
|
||||
|
||||
function handleSaveConfig () {
|
||||
let formatConvertObj = {}
|
||||
try {
|
||||
formatConvertObj = JSON.parse(compressForm.formatConvertObj)
|
||||
} catch (error) {
|
||||
}
|
||||
const formatConvertObjEntries = Object.entries(formatConvertObj)
|
||||
const formatConvertObjEntriesFilter = formatConvertObjEntries.filter((item: any) => {
|
||||
return imageExtList.includes(item[0]) && availableFormat.includes(item[1])
|
||||
})
|
||||
const formatConvertObjFilter = Object.fromEntries(formatConvertObjEntriesFilter)
|
||||
compressForm.formatConvertObj = formatConvertObjFilter
|
||||
saveConfig('buildIn.compress', toRaw(compressForm))
|
||||
saveConfig('buildIn.watermark', toRaw(waterMarkForm))
|
||||
closeDialog()
|
||||
@@ -534,6 +559,11 @@ async function initData () {
|
||||
compressForm.isRemoveExif = compress.isRemoveExif ?? false
|
||||
compressForm.isFlip = compress.isFlip ?? false
|
||||
compressForm.isFlop = compress.isFlop ?? false
|
||||
try {
|
||||
compressForm.formatConvertObj = JSON.stringify(compress.formatConvertObj ?? {})
|
||||
} catch (error) {
|
||||
compressForm.formatConvertObj = '{}'
|
||||
}
|
||||
}
|
||||
if (watermark) {
|
||||
waterMarkForm.isAddWatermark = watermark.isAddWatermark ?? false
|
||||
|
||||
1
src/universal/types/i18n.d.ts
vendored
1
src/universal/types/i18n.d.ts
vendored
@@ -117,6 +117,7 @@ interface ILocales {
|
||||
UPLOAD_PAGE_IMAGE_PROCESS_QUALITY: string
|
||||
UPLOAD_PAGE_IMAGE_PROCESS_ISCONVERT: string
|
||||
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT: string
|
||||
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT_SPECIFIC: string
|
||||
UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP: string
|
||||
UPLOAD_PAGE_IMAGE_PROCESS_ISFLOP: string
|
||||
UPLOAD_PAGE_IMAGE_PROCESS_ISRESIZE: string
|
||||
|
||||
Reference in New Issue
Block a user