From 7c2559192a655f1318a6a6e36eed58399880a045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B0=8F=E6=9C=AF?= Date: Thu, 11 Nov 2021 10:54:44 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 2 ++ package.json | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index effa77a..3d81d76 100644 --- a/index.js +++ b/index.js @@ -14,11 +14,13 @@ const opts = { const create = async function (options) { options = Object.assign({}, opts, options); const { width, height, size, url } = options; + let image = url; if (isUrl(url)) { const axiosData = await axios({ url, responseType: "arraybuffer" }); image = axiosData.data; } + const baseImage = await sharp(image).resize(width, height).png().toBuffer(); const left = randomRangeNum(size, width - size); const top = randomRangeNum(size, height - size); diff --git a/package.json b/package.json index 7f0701f..1fbc9a5 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,11 @@ "description": "生成滑动验证码拼图图片和背景图片", "main": "index.js", "scripts": { - "test": "node test.js" + "test": "node test.js", + "version patch": "npm version patch", + "version minor": "npm version minor", + "version major": "npm version major", + "publish": "npm publish" }, "repository": { "type": "git",