mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 14:48:13 -05:00
✨ Feature(custom): support specific format option for image conversion
ISSUES CLOSED: #124
This commit is contained in:
parent
bc31581c0b
commit
9083a1cce5
@ -120,6 +120,7 @@ UPLOAD_PAGE_IMAGE_PROCESS_ISREMOVEEXIF: Remove EXIF Info
|
|||||||
UPLOAD_PAGE_IMAGE_PROCESS_QUALITY: Compression Quality
|
UPLOAD_PAGE_IMAGE_PROCESS_QUALITY: Compression Quality
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISCONVERT: Convert Format
|
UPLOAD_PAGE_IMAGE_PROCESS_ISCONVERT: Convert Format
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT: Destination Format
|
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT: Destination Format
|
||||||
|
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT_SPECIFIC: 'Specific Format, Please enter in json format, e.g. {"png": "jpg"}'
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP: Whether to flip vertically
|
UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP: Whether to flip vertically
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISFLOP: Whether to flip horizontally
|
UPLOAD_PAGE_IMAGE_PROCESS_ISFLOP: Whether to flip horizontally
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISRESIZE: Resize to fixed size
|
UPLOAD_PAGE_IMAGE_PROCESS_ISRESIZE: Resize to fixed size
|
||||||
|
@ -120,6 +120,7 @@ UPLOAD_PAGE_IMAGE_PROCESS_ISREMOVEEXIF: 是否移除EXIF信息
|
|||||||
UPLOAD_PAGE_IMAGE_PROCESS_QUALITY: 压缩质量
|
UPLOAD_PAGE_IMAGE_PROCESS_QUALITY: 压缩质量
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISCONVERT: 是否转换格式
|
UPLOAD_PAGE_IMAGE_PROCESS_ISCONVERT: 是否转换格式
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT: 转换目的格式
|
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT: 转换目的格式
|
||||||
|
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT_SPECIFIC: '精细化转换格式, 请输入JSON格式,如: {"png": "jpg"}'
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP: 是否进行垂直翻转
|
UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP: 是否进行垂直翻转
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISFLOP: 是否进行水平翻转
|
UPLOAD_PAGE_IMAGE_PROCESS_ISFLOP: 是否进行水平翻转
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISRESIZE: 是否按固定尺寸调整图片
|
UPLOAD_PAGE_IMAGE_PROCESS_ISRESIZE: 是否按固定尺寸调整图片
|
||||||
|
@ -120,6 +120,7 @@ UPLOAD_PAGE_IMAGE_PROCESS_ISREMOVEEXIF: 是否移除EXIF信息
|
|||||||
UPLOAD_PAGE_IMAGE_PROCESS_QUALITY: 壓縮質量
|
UPLOAD_PAGE_IMAGE_PROCESS_QUALITY: 壓縮質量
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISCONVERT: 是否轉換格式
|
UPLOAD_PAGE_IMAGE_PROCESS_ISCONVERT: 是否轉換格式
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT: 轉換目的格式
|
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT: 轉換目的格式
|
||||||
|
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT_SPECIFIC: '指定格式, 请输入JSON格式配置,如{"jpg":"png"}'
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP: 是否進行垂直翻轉
|
UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP: 是否進行垂直翻轉
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISFLOP: 是否進行水平翻轉
|
UPLOAD_PAGE_IMAGE_PROCESS_ISFLOP: 是否進行水平翻轉
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISRESIZE: 是否按固定尺寸調整圖片
|
UPLOAD_PAGE_IMAGE_PROCESS_ISRESIZE: 是否按固定尺寸調整圖片
|
||||||
|
@ -1472,6 +1472,17 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</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
|
<el-form-item
|
||||||
:label="$T('UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP')"
|
:label="$T('UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP')"
|
||||||
>
|
>
|
||||||
@ -1664,6 +1675,8 @@ const waterMarkPositionMap = new Map([
|
|||||||
['centre', $T('UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER')]
|
['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 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>({
|
const waterMarkForm = reactive<any>({
|
||||||
@ -1686,13 +1699,15 @@ const compressForm = reactive<any>({
|
|||||||
isReSize: false,
|
isReSize: false,
|
||||||
reSizeWidth: 500,
|
reSizeWidth: 500,
|
||||||
reSizeHeight: 500,
|
reSizeHeight: 500,
|
||||||
|
skipReSizeOfSmallImg: false,
|
||||||
isReSizeByPercent: false,
|
isReSizeByPercent: false,
|
||||||
reSizePercent: 50,
|
reSizePercent: 50,
|
||||||
isRotate: false,
|
isRotate: false,
|
||||||
rotateDegree: 0,
|
rotateDegree: 0,
|
||||||
isRemoveExif: false,
|
isRemoveExif: false,
|
||||||
isFlip: false,
|
isFlip: false,
|
||||||
isFlop: false
|
isFlop: false,
|
||||||
|
formatConvertObj: '{}'
|
||||||
})
|
})
|
||||||
|
|
||||||
function closeDialog () {
|
function closeDialog () {
|
||||||
@ -1700,6 +1715,17 @@ function closeDialog () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleSaveConfig () {
|
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.compress', toRaw(compressForm))
|
||||||
saveConfig('buildIn.watermark', toRaw(waterMarkForm))
|
saveConfig('buildIn.watermark', toRaw(waterMarkForm))
|
||||||
closeDialog()
|
closeDialog()
|
||||||
@ -1723,6 +1749,11 @@ async function initForm () {
|
|||||||
compressForm.isRemoveExif = compress.isRemoveExif ?? false
|
compressForm.isRemoveExif = compress.isRemoveExif ?? false
|
||||||
compressForm.isFlip = compress.isFlip ?? false
|
compressForm.isFlip = compress.isFlip ?? false
|
||||||
compressForm.isFlop = compress.isFlop ?? false
|
compressForm.isFlop = compress.isFlop ?? false
|
||||||
|
try {
|
||||||
|
compressForm.formatConvertObj = JSON.stringify(compress.formatConvertObj ?? {})
|
||||||
|
} catch (error) {
|
||||||
|
compressForm.formatConvertObj = '{}'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (watermark) {
|
if (watermark) {
|
||||||
waterMarkForm.isAddWatermark = watermark.isAddWatermark ?? false
|
waterMarkForm.isAddWatermark = watermark.isAddWatermark ?? false
|
||||||
|
@ -303,6 +303,17 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</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
|
<el-form-item
|
||||||
:label="$T('UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP')"
|
:label="$T('UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP')"
|
||||||
>
|
>
|
||||||
@ -474,6 +485,8 @@ const waterMarkPositionMap = new Map([
|
|||||||
['centre', $T('UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER')]
|
['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 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>({
|
const waterMarkForm = reactive<any>({
|
||||||
@ -503,7 +516,8 @@ const compressForm = reactive<any>({
|
|||||||
rotateDegree: 0,
|
rotateDegree: 0,
|
||||||
isRemoveExif: false,
|
isRemoveExif: false,
|
||||||
isFlip: false,
|
isFlip: false,
|
||||||
isFlop: false
|
isFlop: false,
|
||||||
|
formatConvertObj: '{}'
|
||||||
})
|
})
|
||||||
|
|
||||||
function closeDialog () {
|
function closeDialog () {
|
||||||
@ -511,6 +525,17 @@ function closeDialog () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleSaveConfig () {
|
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.compress', toRaw(compressForm))
|
||||||
saveConfig('buildIn.watermark', toRaw(waterMarkForm))
|
saveConfig('buildIn.watermark', toRaw(waterMarkForm))
|
||||||
closeDialog()
|
closeDialog()
|
||||||
@ -534,6 +559,11 @@ async function initData () {
|
|||||||
compressForm.isRemoveExif = compress.isRemoveExif ?? false
|
compressForm.isRemoveExif = compress.isRemoveExif ?? false
|
||||||
compressForm.isFlip = compress.isFlip ?? false
|
compressForm.isFlip = compress.isFlip ?? false
|
||||||
compressForm.isFlop = compress.isFlop ?? false
|
compressForm.isFlop = compress.isFlop ?? false
|
||||||
|
try {
|
||||||
|
compressForm.formatConvertObj = JSON.stringify(compress.formatConvertObj ?? {})
|
||||||
|
} catch (error) {
|
||||||
|
compressForm.formatConvertObj = '{}'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (watermark) {
|
if (watermark) {
|
||||||
waterMarkForm.isAddWatermark = watermark.isAddWatermark ?? false
|
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_QUALITY: string
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISCONVERT: string
|
UPLOAD_PAGE_IMAGE_PROCESS_ISCONVERT: string
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT: string
|
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT: string
|
||||||
|
UPLOAD_PAGE_IMAGE_PROCESS_CONVERTFORMAT_SPECIFIC: string
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP: string
|
UPLOAD_PAGE_IMAGE_PROCESS_ISFLIP: string
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISFLOP: string
|
UPLOAD_PAGE_IMAGE_PROCESS_ISFLOP: string
|
||||||
UPLOAD_PAGE_IMAGE_PROCESS_ISRESIZE: string
|
UPLOAD_PAGE_IMAGE_PROCESS_ISRESIZE: string
|
||||||
|
Loading…
Reference in New Issue
Block a user