webp全部导出插件
This commit is contained in:
parent
03c14b4ab8
commit
a7d11e8600
@ -14444,7 +14444,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
canvas.width = img.width
|
canvas.width = img.width
|
||||||
canvas.height = img.height
|
canvas.height = img.height
|
||||||
ctx.drawImage(img, 0, 0)
|
ctx.drawImage(img, 0, 0)
|
||||||
const webpDataURL = canvas.toDataURL("image/webp", 1) //第二个参数为画面质量,范围为0-1,1为无损
|
const webpDataURL = canvas.toDataURL("image/webp", 0.85) //第二个参数为画面质量,范围为0-1,1为无损
|
||||||
console.log(webpDataURL)
|
console.log(webpDataURL)
|
||||||
const link = document.createElement("a")
|
const link = document.createElement("a")
|
||||||
link.href = webpDataURL
|
link.href = webpDataURL
|
||||||
@ -14452,5 +14452,23 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
link.download = name + ".webp"
|
link.download = name + ".webp"
|
||||||
link.click()
|
link.click()
|
||||||
}
|
}
|
||||||
|
this.towebpall = function () {
|
||||||
|
const canvas = document.createElement('canvas'); //背景画布设置
|
||||||
|
const ctx = canvas.getContext("2d")
|
||||||
|
|
||||||
|
core.material.images.image.forEach((img) => {
|
||||||
|
core.clearMap(ctx)
|
||||||
|
canvas.width = img.width
|
||||||
|
canvas.height = img.height
|
||||||
|
ctx.drawImage(img, 0, 0)
|
||||||
|
const webpDataURL = canvas.toDataURL("image/webp", 0.85) //第二个参数为画面质量,范围为0-1,1为无损
|
||||||
|
console.log(webpDataURL)
|
||||||
|
const link = document.createElement("a")
|
||||||
|
link.href = webpDataURL
|
||||||
|
const name = image.substring(0, image.indexOf("."))
|
||||||
|
link.download = name + ".webp"
|
||||||
|
link.click()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user