zet-lib 1.2.64 → 1.2.65
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/lib/Util.js +8 -0
- package/package.json +1 -1
package/lib/Util.js
CHANGED
|
@@ -1079,6 +1079,14 @@ Util.findFilesName = (arr = [], filename = '') => {
|
|
|
1079
1079
|
return arr.filter((item) => item.includes(filename))
|
|
1080
1080
|
}
|
|
1081
1081
|
|
|
1082
|
+
//convert image file to base64
|
|
1083
|
+
Util.imageFiletoBase64 = (imgPath) => {
|
|
1084
|
+
// read image file
|
|
1085
|
+
const base64Image = fs.readFileSync(imgPath, 'base64')
|
|
1086
|
+
const extensionName = path.extname(imgPath)
|
|
1087
|
+
return `data:image/${extensionName.split('.').pop()};base64,${base64Image}`
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1082
1090
|
Util.getFiles = function (dir, token = '') {
|
|
1083
1091
|
let arr = fs.readdirSync(dir)
|
|
1084
1092
|
let folders = ''
|