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.
@@ -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.stats.isFile()
110
+ f.isFile
110
111
  && !RE_THUMB.test(f.path)
111
- && f.stats.size > minFileSize
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(helper._omit(t, "stats", "bar1"))
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 (iw <= maxSide && ih <= maxSide) {
364
- return { dstWidth: iw, dstHeight: ih }
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)