piclist 2.0.1 → 2.0.2
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/CHANGELOG.md +8 -0
- package/README.md +77 -77
- package/README_en.md +249 -0
- package/dist/index.js +2 -2
- package/dist/types/index.d.ts +112 -0
- package/dist/utils/common.d.ts +3 -1
- package/package.json +1 -1
- package/README_cn.md +0 -249
package/dist/types/index.d.ts
CHANGED
|
@@ -537,6 +537,53 @@ export interface II18nManager {
|
|
|
537
537
|
export type availableConvertFormat = keyof FormatEnum;
|
|
538
538
|
export type availableWatermarkPosition = keyof GravityEnum;
|
|
539
539
|
export interface IBuildInWaterMarkOptions {
|
|
540
|
+
isAddWatermark?: boolean;
|
|
541
|
+
isAddWatermarkMap?: {
|
|
542
|
+
[key: string]: boolean;
|
|
543
|
+
};
|
|
544
|
+
watermarkType?: 'text' | 'image';
|
|
545
|
+
watermarkTypeMap?: {
|
|
546
|
+
[key: string]: 'text' | 'image';
|
|
547
|
+
};
|
|
548
|
+
isFullScreenWatermark?: boolean;
|
|
549
|
+
isFullScreenWatermarkMap?: {
|
|
550
|
+
[key: string]: boolean;
|
|
551
|
+
};
|
|
552
|
+
watermarkDegree?: number;
|
|
553
|
+
watermarkDegreeMap?: {
|
|
554
|
+
[key: string]: number;
|
|
555
|
+
};
|
|
556
|
+
watermarkText?: string;
|
|
557
|
+
watermarkTextMap?: {
|
|
558
|
+
[key: string]: string;
|
|
559
|
+
};
|
|
560
|
+
watermarkFontPath?: string;
|
|
561
|
+
watermarkFontPathMap?: {
|
|
562
|
+
[key: string]: string;
|
|
563
|
+
};
|
|
564
|
+
watermarkScaleRatio?: number;
|
|
565
|
+
watermarkScaleRatioMap?: {
|
|
566
|
+
[key: string]: number;
|
|
567
|
+
};
|
|
568
|
+
watermarkColor?: string;
|
|
569
|
+
watermarkColorMap?: {
|
|
570
|
+
[key: string]: string;
|
|
571
|
+
};
|
|
572
|
+
watermarkImagePath?: string;
|
|
573
|
+
watermarkImagePathMap?: {
|
|
574
|
+
[key: string]: string;
|
|
575
|
+
};
|
|
576
|
+
watermarkPosition?: availableWatermarkPosition;
|
|
577
|
+
watermarkPositionMap?: {
|
|
578
|
+
[key: string]: availableWatermarkPosition;
|
|
579
|
+
};
|
|
580
|
+
watermarkImageOpacity?: number;
|
|
581
|
+
watermarkImageOpacityMap?: {
|
|
582
|
+
[key: string]: number;
|
|
583
|
+
};
|
|
584
|
+
[propName: string]: any;
|
|
585
|
+
}
|
|
586
|
+
export interface IBuildInWaterMarkOptionsTreated {
|
|
540
587
|
isAddWatermark?: boolean;
|
|
541
588
|
watermarkType?: 'text' | 'image';
|
|
542
589
|
isFullScreenWatermark?: boolean;
|
|
@@ -548,8 +595,72 @@ export interface IBuildInWaterMarkOptions {
|
|
|
548
595
|
watermarkImagePath?: string;
|
|
549
596
|
watermarkPosition?: availableWatermarkPosition;
|
|
550
597
|
watermarkImageOpacity?: number;
|
|
598
|
+
[propName: string]: any;
|
|
551
599
|
}
|
|
552
600
|
export interface IBuildInCompressOptions {
|
|
601
|
+
quality?: number;
|
|
602
|
+
qualityMap?: {
|
|
603
|
+
[key: string]: number;
|
|
604
|
+
};
|
|
605
|
+
isConvert?: boolean;
|
|
606
|
+
isConvertMap?: {
|
|
607
|
+
[key: string]: boolean;
|
|
608
|
+
};
|
|
609
|
+
convertFormat?: availableConvertFormat;
|
|
610
|
+
convertFormatMap?: {
|
|
611
|
+
[key: string]: availableConvertFormat;
|
|
612
|
+
};
|
|
613
|
+
isReSize?: boolean;
|
|
614
|
+
isReSizeMap?: {
|
|
615
|
+
[key: string]: boolean;
|
|
616
|
+
};
|
|
617
|
+
reSizeWidth?: number;
|
|
618
|
+
reSizeWidthMap?: {
|
|
619
|
+
[key: string]: number;
|
|
620
|
+
};
|
|
621
|
+
reSizeHeight?: number;
|
|
622
|
+
reSizeHeightMap?: {
|
|
623
|
+
[key: string]: number;
|
|
624
|
+
};
|
|
625
|
+
skipReSizeOfSmallImg?: boolean;
|
|
626
|
+
skipReSizeOfSmallImgMap?: {
|
|
627
|
+
[key: string]: boolean;
|
|
628
|
+
};
|
|
629
|
+
isReSizeByPercent?: boolean;
|
|
630
|
+
isReSizeByPercentMap?: {
|
|
631
|
+
[key: string]: boolean;
|
|
632
|
+
};
|
|
633
|
+
reSizePercent?: number;
|
|
634
|
+
reSizePercentMap?: {
|
|
635
|
+
[key: string]: number;
|
|
636
|
+
};
|
|
637
|
+
isRotate?: boolean;
|
|
638
|
+
isRotateMap?: {
|
|
639
|
+
[key: string]: boolean;
|
|
640
|
+
};
|
|
641
|
+
rotateDegree?: number;
|
|
642
|
+
rotateDegreeMap?: {
|
|
643
|
+
[key: string]: number;
|
|
644
|
+
};
|
|
645
|
+
isRemoveExif?: boolean;
|
|
646
|
+
isRemoveExifMap?: {
|
|
647
|
+
[key: string]: boolean;
|
|
648
|
+
};
|
|
649
|
+
isFlip?: boolean;
|
|
650
|
+
isFlipMap?: {
|
|
651
|
+
[key: string]: boolean;
|
|
652
|
+
};
|
|
653
|
+
isFlop?: boolean;
|
|
654
|
+
isFlopMap?: {
|
|
655
|
+
[key: string]: boolean;
|
|
656
|
+
};
|
|
657
|
+
formatConvertObj?: any;
|
|
658
|
+
formatConvertObjMap?: {
|
|
659
|
+
[key: string]: any;
|
|
660
|
+
};
|
|
661
|
+
[propName: string]: any;
|
|
662
|
+
}
|
|
663
|
+
export interface IBuildInCompressOptionsTreated {
|
|
553
664
|
quality?: number;
|
|
554
665
|
isConvert?: boolean;
|
|
555
666
|
convertFormat?: availableConvertFormat;
|
|
@@ -564,6 +675,7 @@ export interface IBuildInCompressOptions {
|
|
|
564
675
|
isRemoveExif?: boolean;
|
|
565
676
|
isFlip?: boolean;
|
|
566
677
|
isFlop?: boolean;
|
|
678
|
+
formatConvertObj?: any;
|
|
567
679
|
[propName: string]: any;
|
|
568
680
|
}
|
|
569
681
|
export interface IBuildInSkipProcessOptions {
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import sharp from 'sharp';
|
|
3
|
-
import type { IBuildInCompressOptions, IBuildInWaterMarkOptions, IImgSize, ILogger, IPathTransformedImgInfo, IPicGo, IPluginNameType } from '../types';
|
|
3
|
+
import type { IBuildInCompressOptions, IBuildInCompressOptionsTreated, IBuildInWaterMarkOptions, IBuildInWaterMarkOptionsTreated, IImgSize, ILogger, IPathTransformedImgInfo, IPicGo, IPluginNameType } from '../types';
|
|
4
4
|
export declare function randomStringGenerator(length: number): string;
|
|
5
5
|
export declare function renameFileNameWithTimestamp(oldName: string): string;
|
|
6
6
|
export declare function renameFileNameWithRandomString(oldName: string, length?: number): string;
|
|
@@ -34,6 +34,8 @@ export declare function safeParse<T>(str: string): T | string;
|
|
|
34
34
|
export declare const forceNumber: (num?: string | number) => number;
|
|
35
35
|
export declare const isDev: () => boolean;
|
|
36
36
|
export declare function AddWatermark(img: Buffer, watermarkType: 'text' | 'image', defaultWatermarkFontPath: string, isFullScreenWatermark?: boolean, watermarkDegree?: number, text?: string, watermarkFontPath?: string, watermarkScaleRatio?: number, watermarkColor?: string, watermarkImagePath?: string, position?: sharp.Gravity, watermarkImageOpacity?: number): Promise<Buffer>;
|
|
37
|
+
export declare function getTreatedWaterMarkOptions(raw: IBuildInWaterMarkOptions | undefined, picBed: string): IBuildInWaterMarkOptionsTreated;
|
|
38
|
+
export declare function getTreatedCompressOptions(raw: IBuildInCompressOptions | undefined, picBed: string): IBuildInCompressOptionsTreated;
|
|
37
39
|
export declare function imageAddWaterMark(img: Buffer, options: IBuildInWaterMarkOptions, defaultWatermarkFontPath: string, logger: ILogger): Promise<Buffer>;
|
|
38
40
|
export declare function imageCompress(img: Buffer, options: IBuildInCompressOptions, rawFormat: string, logger: ILogger): Promise<Buffer>;
|
|
39
41
|
export declare function getConvertedFormat(options: IBuildInCompressOptions | undefined, rawFormat: string): string;
|
package/package.json
CHANGED
package/README_cn.md
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
# PicList-Core
|
|
2
|
-
|
|
3
|
-
[English](./README.md) | 简体中文
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
8
|
-
|
|
9
|
-

|
|
10
|
-
|
|
11
|
-
PicList-Core 是一个功能强大的图片上传工具,提供 CLI 和 API 两种调用方式。它在 PicGo-Core 的基础上增强了功能,同时保持插件兼容性。查看 [Awesome-PicGo](https://github.com/PicGo/Awesome-PicGo) 获取丰富的插件资源。
|
|
12
|
-
|
|
13
|
-
你可以查看 [PiclList-Core 的 DeepWiki](https://deepwiki.com/Kuingsmile/PicList-Core/) 获取更多信息。
|
|
14
|
-
|
|
15
|
-
**原生支持 Typora 集成**。
|
|
16
|
-
|
|
17
|
-
## 增强功能
|
|
18
|
-
|
|
19
|
-
- **图像处理能力**:
|
|
20
|
-
- 添加水印、压缩图片和转换格式
|
|
21
|
-
- 通过 `picgo set buildin watermark` 和 `picgo set buildin compress` CLI 命令进行配置
|
|
22
|
-
- 处理过程发生在 beforeTransform 阶段,确保与所有插件兼容
|
|
23
|
-
|
|
24
|
-
- **高级重命名**:
|
|
25
|
-
- 通过 `picgo set buildin rename` 设置自定义重命名规则
|
|
26
|
-
|
|
27
|
-
- **额外内置图床**:
|
|
28
|
-
- WebDAV、SFTP、本地路径、AWS S3
|
|
29
|
-
- 改进的 Imgur 支持,支持账户上传
|
|
30
|
-
|
|
31
|
-
- **内置服务器**:
|
|
32
|
-
- 类似于 PicList-Desktop 服务器
|
|
33
|
-
- 使用 `picgo-server` 命令启动
|
|
34
|
-
|
|
35
|
-
- **错误修复**:
|
|
36
|
-
- 解决了原始 PicGo-Core 的多个问题
|
|
37
|
-
|
|
38
|
-
## 安装
|
|
39
|
-
|
|
40
|
-
PicList 需要 Node.js >= 20
|
|
41
|
-
|
|
42
|
-
### 前置条件
|
|
43
|
-
|
|
44
|
-
PicList 依赖 [sharp](https://sharp.pixelplumbing.com/),请先安装它:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npm config set sharp_binary_host "https://npmmirror.com/mirrors/sharp"
|
|
48
|
-
npm config set sharp_libvips_binary_host "https://npmmirror.com/mirrors/sharp-libvips"
|
|
49
|
-
npm install sharp
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### 全局安装
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
npm install piclist -g
|
|
56
|
-
|
|
57
|
-
# 或者
|
|
58
|
-
|
|
59
|
-
yarn global add piclist
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### 本地安装
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
npm install piclist -D
|
|
66
|
-
|
|
67
|
-
# 或者
|
|
68
|
-
|
|
69
|
-
yarn add piclist -D
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## 使用方法
|
|
73
|
-
|
|
74
|
-
### Docker
|
|
75
|
-
|
|
76
|
-
你可以使用Docker运行PicList-Core。
|
|
77
|
-
|
|
78
|
-
#### docker run
|
|
79
|
-
|
|
80
|
-
将`./piclist`更改为你自己的路径,该路径是放置`config.json`文件的位置,并将`piclist123456`更改为你自己的密钥。
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
docker run -d \
|
|
84
|
-
--name piclist \
|
|
85
|
-
--restart always \
|
|
86
|
-
-p 36677:36677 \
|
|
87
|
-
-v "./piclist:/root/.piclist" \
|
|
88
|
-
kuingsmile/piclist:latest \
|
|
89
|
-
node /usr/local/bin/picgo-server -k piclist123456
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
#### docker-compose
|
|
93
|
-
|
|
94
|
-
从本仓库下载`docker-compose.yml`,或将以下内容复制到`docker-compose.yml`:
|
|
95
|
-
|
|
96
|
-
```yaml
|
|
97
|
-
version: '3.3'
|
|
98
|
-
|
|
99
|
-
services:
|
|
100
|
-
node:
|
|
101
|
-
image: 'kuingsmile/piclist:latest'
|
|
102
|
-
container_name: piclist
|
|
103
|
-
restart: always
|
|
104
|
-
ports:
|
|
105
|
-
- 36677:36677
|
|
106
|
-
volumes:
|
|
107
|
-
- './piclist:/root/.piclist'
|
|
108
|
-
command: node /usr/local/bin/picgo-server -k piclist123456
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
你可以将`./piclist`更改为你自己的路径,该路径是放置`config.json`文件的位置,并在`command`中更改密钥。
|
|
112
|
-
|
|
113
|
-
然后运行:
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
docker-compose up -d
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
#### 在Docker中安装插件
|
|
120
|
-
|
|
121
|
-
你可以使用`docker exec`在Docker中安装插件。
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
docker exec -it piclist sh
|
|
125
|
-
picgo install picgo-plugin-xxx
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
#### 在Docker中更新配置
|
|
129
|
-
|
|
130
|
-
你可以使用`docker exec`在Docker中更新配置。
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
docker exec -it piclist sh
|
|
134
|
-
picgo set xxx
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### 服务器
|
|
138
|
-
|
|
139
|
-
你可以使用`picgo-server`启动服务器,默认端口为`36677`。
|
|
140
|
-
|
|
141
|
-
启动服务器:
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
picgo-server
|
|
145
|
-
node ./bin/picgo-server
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
> 强烈建议添加`--key`参数以避免未经授权的访问。例如:`picgo-server --key 123456`
|
|
149
|
-
|
|
150
|
-
显示帮助:
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
$ picgo-server -h
|
|
154
|
-
|
|
155
|
-
Usage: picgo-server [options]
|
|
156
|
-
|
|
157
|
-
Options:
|
|
158
|
-
|
|
159
|
-
-h, --help 显示帮助信息
|
|
160
|
-
-c, --config 设置配置路径
|
|
161
|
-
-p, --port 设置端口,默认端口为36677
|
|
162
|
-
--host 设置主机,默认主机为0.0.0.0
|
|
163
|
-
-k, --key 设置密钥以避免未经授权的访问
|
|
164
|
-
-v, --version 显示版本号
|
|
165
|
-
|
|
166
|
-
Examples:
|
|
167
|
-
picgo-server -c /path/to/config.json
|
|
168
|
-
picgo-server -k 123456
|
|
169
|
-
picgo-server -c /path/to/config.json -k 123456
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
#### 接口
|
|
173
|
-
|
|
174
|
-
- `/upload?picbed=xxx&key=xxx` 上传图片,`picbed`用于设置图床,`key`用于设置密钥
|
|
175
|
-
- `/heartbeat` 心跳检测
|
|
176
|
-
|
|
177
|
-
### CLI使用
|
|
178
|
-
|
|
179
|
-
> PicList-Core使用`SM.MS`作为默认上传图床。
|
|
180
|
-
|
|
181
|
-
显示帮助:
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
$ picgo -h
|
|
185
|
-
|
|
186
|
-
Usage: picgo [options] [command]
|
|
187
|
-
|
|
188
|
-
Options:
|
|
189
|
-
|
|
190
|
-
-v, --version 输出版本号
|
|
191
|
-
-d, --debug 调试模式
|
|
192
|
-
-s, --silent 静默模式
|
|
193
|
-
-c, --config <path> 设置配置路径
|
|
194
|
-
-h, --help 输出使用信息
|
|
195
|
-
|
|
196
|
-
Commands:
|
|
197
|
-
|
|
198
|
-
install|add <plugins...> 安装picgo插件
|
|
199
|
-
uninstall|rm <plugins...> 卸载picgo插件
|
|
200
|
-
update <plugins...> 更新picgo插件
|
|
201
|
-
set|config <module> [name] 配置picgo模块
|
|
202
|
-
upload|u [input...] 上传,开始上传
|
|
203
|
-
use [module] 使用picgo模块
|
|
204
|
-
init [options] <template> [project] 创建picgo插件的开发模板
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
#### 从路径上传图片
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
picgo upload /xxx/xx/xx.jpg
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
#### 从剪贴板上传图片
|
|
214
|
-
|
|
215
|
-
> 从剪贴板获取的图片将被转换为`png`格式
|
|
216
|
-
|
|
217
|
-
```bash
|
|
218
|
-
picgo upload
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
### 在Node项目中使用
|
|
222
|
-
|
|
223
|
-
#### CommonJS
|
|
224
|
-
|
|
225
|
-
```js
|
|
226
|
-
const { PicGo } = require('piclist')
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
#### ES模块
|
|
230
|
-
|
|
231
|
-
```js
|
|
232
|
-
import { PicGo } from 'piclist'
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
#### API使用示例
|
|
236
|
-
|
|
237
|
-
```js
|
|
238
|
-
const picgo = new PicGo()
|
|
239
|
-
|
|
240
|
-
// 从路径上传图片
|
|
241
|
-
picgo.upload(['/xxx/xxx.jpg'])
|
|
242
|
-
|
|
243
|
-
// 从剪贴板上传图片
|
|
244
|
-
picgo.upload()
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
## 文档
|
|
248
|
-
|
|
249
|
-
获取更多详细信息,请查看[PicGo-Core文档](https://picgo.github.io/PicGo-Core-Doc/)。
|