mediac 1.7.1 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cmd/cmd_compress.js +6 -5
- package/cmd/cmd_ffmpeg.js +618 -326
- package/cmd/cmd_prefix.js +2 -2
- package/cmd/cmd_remove.js +45 -16
- package/cmd/cmd_rename.js +57 -39
- package/cmd/cmd_shared.js +44 -0
- package/cmd/cmd_zipu.js +1 -1
- package/lib/core.js +77 -1
- package/lib/ffprobe.js +68 -6
- package/lib/helper.js +56 -21
- package/package.json +2 -1
- package/scripts/media_cli.js +10 -4
package/cmd/cmd_compress.js
CHANGED
|
@@ -18,6 +18,7 @@ import { cpus } from "os"
|
|
|
18
18
|
import pMap from 'p-map'
|
|
19
19
|
import path from "path"
|
|
20
20
|
import sharp from "sharp"
|
|
21
|
+
import * as core from '../lib/core.js'
|
|
21
22
|
import * as log from '../lib/debug.js'
|
|
22
23
|
import * as mf from '../lib/file.js'
|
|
23
24
|
import * as helper from '../lib/helper.js'
|
|
@@ -106,9 +107,9 @@ const handler = async function cmdCompress(argv) {
|
|
|
106
107
|
const walkOpts = {
|
|
107
108
|
needStats: true,
|
|
108
109
|
entryFilter: (f) =>
|
|
109
|
-
f.
|
|
110
|
+
f.isFile
|
|
110
111
|
&& !RE_THUMB.test(f.path)
|
|
111
|
-
&& f.
|
|
112
|
+
&& f.size > minFileSize
|
|
112
113
|
&& helper.isImageFile(f.path)
|
|
113
114
|
}
|
|
114
115
|
log.showGreen(logTag, `Walking files ...`)
|
|
@@ -176,7 +177,7 @@ const handler = async function cmdCompress(argv) {
|
|
|
176
177
|
})
|
|
177
178
|
log.show(logTag, `in ${helper.humanTime(startMs)} tasks:`)
|
|
178
179
|
tasks.slice(-1).forEach(t => {
|
|
179
|
-
log.show(
|
|
180
|
+
log.show(core.omit(t, "stats", "bar1"))
|
|
180
181
|
})
|
|
181
182
|
log.info(logTag, argv)
|
|
182
183
|
testMode && log.showYellow("++++++++++ TEST MODE (DRY RUN) ++++++++++")
|
|
@@ -360,8 +361,8 @@ async function purgeSrcFiles(results) {
|
|
|
360
361
|
// 给定图片长宽,给定长边数值,计算缩放后的长宽,只缩小不放大
|
|
361
362
|
function calculateImageScale(imgWidth, imgHeight, maxSide) {
|
|
362
363
|
// 不需要缩放的情况
|
|
363
|
-
if (
|
|
364
|
-
return { dstWidth:
|
|
364
|
+
if (imgWidth <= maxSide && imgHeight <= maxSide) {
|
|
365
|
+
return { dstWidth: imgWidth, dstHeight: imgHeight }
|
|
365
366
|
}
|
|
366
367
|
// 计算缩放比例
|
|
367
368
|
let scaleFactor = maxSide / Math.max(imgWidth, imgHeight)
|