assistsx-js 0.1.22 → 0.1.23
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.
|
@@ -77,6 +77,7 @@ export declare class ImageUtils {
|
|
|
77
77
|
* @param options.scaleWidth 缩放宽度(可选)
|
|
78
78
|
* @param options.scaleHeight 缩放高度(可选)
|
|
79
79
|
* @param options.savePath 保存路径(可选)
|
|
80
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
80
81
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
81
82
|
* @returns Promise<处理后的图片路径>
|
|
82
83
|
*/
|
|
@@ -84,6 +85,7 @@ export declare class ImageUtils {
|
|
|
84
85
|
scaleWidth?: number;
|
|
85
86
|
scaleHeight?: number;
|
|
86
87
|
savePath?: string;
|
|
88
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
87
89
|
timeout?: number;
|
|
88
90
|
}): Promise<string>;
|
|
89
91
|
/**
|
|
@@ -95,6 +97,7 @@ export declare class ImageUtils {
|
|
|
95
97
|
* @param options.width 裁剪宽度(可选,不提供则裁剪到图片右边界)
|
|
96
98
|
* @param options.height 裁剪高度(可选,不提供则裁剪到图片下边界)
|
|
97
99
|
* @param options.savePath 保存路径(可选)
|
|
100
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
98
101
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
99
102
|
* @returns Promise<处理后的图片路径>
|
|
100
103
|
*/
|
|
@@ -104,6 +107,7 @@ export declare class ImageUtils {
|
|
|
104
107
|
width?: number;
|
|
105
108
|
height?: number;
|
|
106
109
|
savePath?: string;
|
|
110
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
107
111
|
timeout?: number;
|
|
108
112
|
}): Promise<string>;
|
|
109
113
|
/**
|
|
@@ -115,6 +119,7 @@ export declare class ImageUtils {
|
|
|
115
119
|
* @param options.px X轴倾斜点(可选)
|
|
116
120
|
* @param options.py Y轴倾斜点(可选)
|
|
117
121
|
* @param options.savePath 保存路径(可选)
|
|
122
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
118
123
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
119
124
|
* @returns Promise<处理后的图片路径>
|
|
120
125
|
*/
|
|
@@ -124,6 +129,7 @@ export declare class ImageUtils {
|
|
|
124
129
|
px?: number;
|
|
125
130
|
py?: number;
|
|
126
131
|
savePath?: string;
|
|
132
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
127
133
|
timeout?: number;
|
|
128
134
|
}): Promise<string>;
|
|
129
135
|
/**
|
|
@@ -134,6 +140,7 @@ export declare class ImageUtils {
|
|
|
134
140
|
* @param options.px 旋转中心X坐标(可选)
|
|
135
141
|
* @param options.py 旋转中心Y坐标(可选)
|
|
136
142
|
* @param options.savePath 保存路径(可选)
|
|
143
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
137
144
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
138
145
|
* @returns Promise<处理后的图片路径>
|
|
139
146
|
*/
|
|
@@ -142,6 +149,7 @@ export declare class ImageUtils {
|
|
|
142
149
|
px?: number;
|
|
143
150
|
py?: number;
|
|
144
151
|
savePath?: string;
|
|
152
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
145
153
|
timeout?: number;
|
|
146
154
|
}): Promise<string>;
|
|
147
155
|
/**
|
|
@@ -149,11 +157,13 @@ export declare class ImageUtils {
|
|
|
149
157
|
* @param imagePath 图片路径
|
|
150
158
|
* @param options 选项
|
|
151
159
|
* @param options.savePath 保存路径(可选)
|
|
160
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
152
161
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
153
162
|
* @returns Promise<处理后的图片路径>
|
|
154
163
|
*/
|
|
155
164
|
toRound(imagePath: string, options?: {
|
|
156
165
|
savePath?: string;
|
|
166
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
157
167
|
timeout?: number;
|
|
158
168
|
}): Promise<string>;
|
|
159
169
|
/**
|
|
@@ -162,12 +172,14 @@ export declare class ImageUtils {
|
|
|
162
172
|
* @param options 选项
|
|
163
173
|
* @param options.radius 圆角半径,默认0
|
|
164
174
|
* @param options.savePath 保存路径(可选)
|
|
175
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
165
176
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
166
177
|
* @returns Promise<处理后的图片路径>
|
|
167
178
|
*/
|
|
168
179
|
toRoundCorner(imagePath: string, options?: {
|
|
169
180
|
radius?: number;
|
|
170
181
|
savePath?: string;
|
|
182
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
171
183
|
timeout?: number;
|
|
172
184
|
}): Promise<string>;
|
|
173
185
|
/**
|
|
@@ -178,6 +190,7 @@ export declare class ImageUtils {
|
|
|
178
190
|
* @param options.color 边框颜色,默认"#000000"
|
|
179
191
|
* @param options.cornerRadius 圆角半径,默认0
|
|
180
192
|
* @param options.savePath 保存路径(可选)
|
|
193
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
181
194
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
182
195
|
* @returns Promise<处理后的图片路径>
|
|
183
196
|
*/
|
|
@@ -186,6 +199,7 @@ export declare class ImageUtils {
|
|
|
186
199
|
color?: string;
|
|
187
200
|
cornerRadius?: number;
|
|
188
201
|
savePath?: string;
|
|
202
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
189
203
|
timeout?: number;
|
|
190
204
|
}): Promise<string>;
|
|
191
205
|
/**
|
|
@@ -195,6 +209,7 @@ export declare class ImageUtils {
|
|
|
195
209
|
* @param options.borderSize 边框大小,默认0
|
|
196
210
|
* @param options.color 边框颜色,默认"#000000"
|
|
197
211
|
* @param options.savePath 保存路径(可选)
|
|
212
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
198
213
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
199
214
|
* @returns Promise<处理后的图片路径>
|
|
200
215
|
*/
|
|
@@ -202,6 +217,7 @@ export declare class ImageUtils {
|
|
|
202
217
|
borderSize?: number;
|
|
203
218
|
color?: string;
|
|
204
219
|
savePath?: string;
|
|
220
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
205
221
|
timeout?: number;
|
|
206
222
|
}): Promise<string>;
|
|
207
223
|
/**
|
|
@@ -210,12 +226,14 @@ export declare class ImageUtils {
|
|
|
210
226
|
* @param options 选项
|
|
211
227
|
* @param options.reflectionHeight 倒影高度,默认0
|
|
212
228
|
* @param options.savePath 保存路径(可选)
|
|
229
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
213
230
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
214
231
|
* @returns Promise<处理后的图片路径>
|
|
215
232
|
*/
|
|
216
233
|
addReflection(imagePath: string, options?: {
|
|
217
234
|
reflectionHeight?: number;
|
|
218
235
|
savePath?: string;
|
|
236
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
219
237
|
timeout?: number;
|
|
220
238
|
}): Promise<string>;
|
|
221
239
|
/**
|
|
@@ -228,6 +246,7 @@ export declare class ImageUtils {
|
|
|
228
246
|
* @param options.color 文字颜色,默认"#000000"
|
|
229
247
|
* @param options.size 文字大小,默认16
|
|
230
248
|
* @param options.savePath 保存路径(可选)
|
|
249
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
231
250
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
232
251
|
* @returns Promise<处理后的图片路径>
|
|
233
252
|
*/
|
|
@@ -238,6 +257,7 @@ export declare class ImageUtils {
|
|
|
238
257
|
color?: string;
|
|
239
258
|
size?: number;
|
|
240
259
|
savePath?: string;
|
|
260
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
241
261
|
timeout?: number;
|
|
242
262
|
}): Promise<string>;
|
|
243
263
|
/**
|
|
@@ -249,6 +269,7 @@ export declare class ImageUtils {
|
|
|
249
269
|
* @param options.y 水印Y坐标,默认0
|
|
250
270
|
* @param options.alpha 透明度,默认255
|
|
251
271
|
* @param options.savePath 保存路径(可选)
|
|
272
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
252
273
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
253
274
|
* @returns Promise<处理后的图片路径>
|
|
254
275
|
*/
|
|
@@ -258,6 +279,7 @@ export declare class ImageUtils {
|
|
|
258
279
|
y?: number;
|
|
259
280
|
alpha?: number;
|
|
260
281
|
savePath?: string;
|
|
282
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
261
283
|
timeout?: number;
|
|
262
284
|
}): Promise<string>;
|
|
263
285
|
/**
|
|
@@ -265,11 +287,13 @@ export declare class ImageUtils {
|
|
|
265
287
|
* @param imagePath 图片路径
|
|
266
288
|
* @param options 选项
|
|
267
289
|
* @param options.savePath 保存路径(可选)
|
|
290
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
268
291
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
269
292
|
* @returns Promise<处理后的图片路径>
|
|
270
293
|
*/
|
|
271
294
|
toAlpha(imagePath: string, options?: {
|
|
272
295
|
savePath?: string;
|
|
296
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
273
297
|
timeout?: number;
|
|
274
298
|
}): Promise<string>;
|
|
275
299
|
/**
|
|
@@ -277,11 +301,13 @@ export declare class ImageUtils {
|
|
|
277
301
|
* @param imagePath 图片路径
|
|
278
302
|
* @param options 选项
|
|
279
303
|
* @param options.savePath 保存路径(可选)
|
|
304
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
280
305
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
281
306
|
* @returns Promise<处理后的图片路径>
|
|
282
307
|
*/
|
|
283
308
|
toGray(imagePath: string, options?: {
|
|
284
309
|
savePath?: string;
|
|
310
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
285
311
|
timeout?: number;
|
|
286
312
|
}): Promise<string>;
|
|
287
313
|
/**
|
|
@@ -291,6 +317,7 @@ export declare class ImageUtils {
|
|
|
291
317
|
* @param options.radius 模糊半径,默认0
|
|
292
318
|
* @param options.scale 缩放比例,默认1
|
|
293
319
|
* @param options.savePath 保存路径(可选)
|
|
320
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
294
321
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
295
322
|
* @returns Promise<处理后的图片路径>
|
|
296
323
|
*/
|
|
@@ -298,6 +325,7 @@ export declare class ImageUtils {
|
|
|
298
325
|
radius?: number;
|
|
299
326
|
scale?: number;
|
|
300
327
|
savePath?: string;
|
|
328
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
301
329
|
timeout?: number;
|
|
302
330
|
}): Promise<string>;
|
|
303
331
|
/**
|
|
@@ -306,12 +334,14 @@ export declare class ImageUtils {
|
|
|
306
334
|
* @param options 选项
|
|
307
335
|
* @param options.radius 模糊半径,默认0
|
|
308
336
|
* @param options.savePath 保存路径(可选)
|
|
337
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
309
338
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
310
339
|
* @returns Promise<处理后的图片路径>
|
|
311
340
|
*/
|
|
312
341
|
renderScriptBlur(imagePath: string, options?: {
|
|
313
342
|
radius?: number;
|
|
314
343
|
savePath?: string;
|
|
344
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
315
345
|
timeout?: number;
|
|
316
346
|
}): Promise<string>;
|
|
317
347
|
/**
|
|
@@ -320,12 +350,14 @@ export declare class ImageUtils {
|
|
|
320
350
|
* @param options 选项
|
|
321
351
|
* @param options.radius 模糊半径,默认0
|
|
322
352
|
* @param options.savePath 保存路径(可选)
|
|
353
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
323
354
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
324
355
|
* @returns Promise<处理后的图片路径>
|
|
325
356
|
*/
|
|
326
357
|
stackBlur(imagePath: string, options?: {
|
|
327
358
|
radius?: number;
|
|
328
359
|
savePath?: string;
|
|
360
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
329
361
|
timeout?: number;
|
|
330
362
|
}): Promise<string>;
|
|
331
363
|
/**
|
|
@@ -335,6 +367,7 @@ export declare class ImageUtils {
|
|
|
335
367
|
* @param options.scaleWidth 缩放宽度(可选)
|
|
336
368
|
* @param options.scaleHeight 缩放高度(可选)
|
|
337
369
|
* @param options.savePath 保存路径(可选)
|
|
370
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
338
371
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
339
372
|
* @returns Promise<压缩后的图片路径>
|
|
340
373
|
*/
|
|
@@ -342,6 +375,7 @@ export declare class ImageUtils {
|
|
|
342
375
|
scaleWidth?: number;
|
|
343
376
|
scaleHeight?: number;
|
|
344
377
|
savePath?: string;
|
|
378
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
345
379
|
timeout?: number;
|
|
346
380
|
}): Promise<string>;
|
|
347
381
|
/**
|
|
@@ -366,12 +400,14 @@ export declare class ImageUtils {
|
|
|
366
400
|
* @param options 选项
|
|
367
401
|
* @param options.sampleSize 采样大小,默认1
|
|
368
402
|
* @param options.savePath 保存路径(可选)
|
|
403
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
369
404
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
370
405
|
* @returns Promise<压缩后的图片路径>
|
|
371
406
|
*/
|
|
372
407
|
compressBySampleSize(imagePath: string, options?: {
|
|
373
408
|
sampleSize?: number;
|
|
374
409
|
savePath?: string;
|
|
410
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
375
411
|
timeout?: number;
|
|
376
412
|
}): Promise<string>;
|
|
377
413
|
/**
|
|
@@ -128,13 +128,14 @@ export class ImageUtils {
|
|
|
128
128
|
* @param options.scaleWidth 缩放宽度(可选)
|
|
129
129
|
* @param options.scaleHeight 缩放高度(可选)
|
|
130
130
|
* @param options.savePath 保存路径(可选)
|
|
131
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
131
132
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
132
133
|
* @returns Promise<处理后的图片路径>
|
|
133
134
|
*/
|
|
134
135
|
async scale(imagePath, options = {}) {
|
|
135
136
|
var _a;
|
|
136
|
-
const { scaleWidth, scaleHeight, savePath, timeout } = options;
|
|
137
|
-
const response = await this.asyncCall("scale", { imagePath, scaleWidth, scaleHeight, savePath }, timeout);
|
|
137
|
+
const { scaleWidth, scaleHeight, savePath, format, timeout } = options;
|
|
138
|
+
const response = await this.asyncCall("scale", { imagePath, scaleWidth, scaleHeight, savePath, format }, timeout);
|
|
138
139
|
if (!response.isSuccess()) {
|
|
139
140
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "缩放图片失败");
|
|
140
141
|
}
|
|
@@ -149,13 +150,14 @@ export class ImageUtils {
|
|
|
149
150
|
* @param options.width 裁剪宽度(可选,不提供则裁剪到图片右边界)
|
|
150
151
|
* @param options.height 裁剪高度(可选,不提供则裁剪到图片下边界)
|
|
151
152
|
* @param options.savePath 保存路径(可选)
|
|
153
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
152
154
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
153
155
|
* @returns Promise<处理后的图片路径>
|
|
154
156
|
*/
|
|
155
157
|
async clip(imagePath, options = {}) {
|
|
156
158
|
var _a;
|
|
157
|
-
const { x = 0, y = 0, width, height, savePath, timeout } = options;
|
|
158
|
-
const response = await this.asyncCall("clip", { imagePath, x, y, width, height, savePath }, timeout);
|
|
159
|
+
const { x = 0, y = 0, width, height, savePath, format, timeout } = options;
|
|
160
|
+
const response = await this.asyncCall("clip", { imagePath, x, y, width, height, savePath, format }, timeout);
|
|
159
161
|
if (!response.isSuccess()) {
|
|
160
162
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "裁剪图片失败");
|
|
161
163
|
}
|
|
@@ -170,13 +172,14 @@ export class ImageUtils {
|
|
|
170
172
|
* @param options.px X轴倾斜点(可选)
|
|
171
173
|
* @param options.py Y轴倾斜点(可选)
|
|
172
174
|
* @param options.savePath 保存路径(可选)
|
|
175
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
173
176
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
174
177
|
* @returns Promise<处理后的图片路径>
|
|
175
178
|
*/
|
|
176
179
|
async skew(imagePath, options = {}) {
|
|
177
180
|
var _a;
|
|
178
|
-
const { kx = 0, ky = 0, px, py, savePath, timeout } = options;
|
|
179
|
-
const response = await this.asyncCall("skew", { imagePath, kx, ky, px, py, savePath }, timeout);
|
|
181
|
+
const { kx = 0, ky = 0, px, py, savePath, format, timeout } = options;
|
|
182
|
+
const response = await this.asyncCall("skew", { imagePath, kx, ky, px, py, savePath, format }, timeout);
|
|
180
183
|
if (!response.isSuccess()) {
|
|
181
184
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "倾斜图片失败");
|
|
182
185
|
}
|
|
@@ -190,13 +193,14 @@ export class ImageUtils {
|
|
|
190
193
|
* @param options.px 旋转中心X坐标(可选)
|
|
191
194
|
* @param options.py 旋转中心Y坐标(可选)
|
|
192
195
|
* @param options.savePath 保存路径(可选)
|
|
196
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
193
197
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
194
198
|
* @returns Promise<处理后的图片路径>
|
|
195
199
|
*/
|
|
196
200
|
async rotate(imagePath, options = {}) {
|
|
197
201
|
var _a;
|
|
198
|
-
const { degree = 0, px, py, savePath, timeout } = options;
|
|
199
|
-
const response = await this.asyncCall("rotate", { imagePath, degree, px, py, savePath }, timeout);
|
|
202
|
+
const { degree = 0, px, py, savePath, format, timeout } = options;
|
|
203
|
+
const response = await this.asyncCall("rotate", { imagePath, degree, px, py, savePath, format }, timeout);
|
|
200
204
|
if (!response.isSuccess()) {
|
|
201
205
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "旋转图片失败");
|
|
202
206
|
}
|
|
@@ -207,13 +211,14 @@ export class ImageUtils {
|
|
|
207
211
|
* @param imagePath 图片路径
|
|
208
212
|
* @param options 选项
|
|
209
213
|
* @param options.savePath 保存路径(可选)
|
|
214
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
210
215
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
211
216
|
* @returns Promise<处理后的图片路径>
|
|
212
217
|
*/
|
|
213
218
|
async toRound(imagePath, options = {}) {
|
|
214
219
|
var _a;
|
|
215
|
-
const { savePath, timeout } = options;
|
|
216
|
-
const response = await this.asyncCall("toRound", { imagePath, savePath }, timeout);
|
|
220
|
+
const { savePath, format, timeout } = options;
|
|
221
|
+
const response = await this.asyncCall("toRound", { imagePath, savePath, format }, timeout);
|
|
217
222
|
if (!response.isSuccess()) {
|
|
218
223
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "转为圆形图片失败");
|
|
219
224
|
}
|
|
@@ -225,13 +230,14 @@ export class ImageUtils {
|
|
|
225
230
|
* @param options 选项
|
|
226
231
|
* @param options.radius 圆角半径,默认0
|
|
227
232
|
* @param options.savePath 保存路径(可选)
|
|
233
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
228
234
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
229
235
|
* @returns Promise<处理后的图片路径>
|
|
230
236
|
*/
|
|
231
237
|
async toRoundCorner(imagePath, options = {}) {
|
|
232
238
|
var _a;
|
|
233
|
-
const { radius = 0, savePath, timeout } = options;
|
|
234
|
-
const response = await this.asyncCall("toRoundCorner", { imagePath, radius, savePath }, timeout);
|
|
239
|
+
const { radius = 0, savePath, format, timeout } = options;
|
|
240
|
+
const response = await this.asyncCall("toRoundCorner", { imagePath, radius, savePath, format }, timeout);
|
|
235
241
|
if (!response.isSuccess()) {
|
|
236
242
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "转为圆角图片失败");
|
|
237
243
|
}
|
|
@@ -245,13 +251,14 @@ export class ImageUtils {
|
|
|
245
251
|
* @param options.color 边框颜色,默认"#000000"
|
|
246
252
|
* @param options.cornerRadius 圆角半径,默认0
|
|
247
253
|
* @param options.savePath 保存路径(可选)
|
|
254
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
248
255
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
249
256
|
* @returns Promise<处理后的图片路径>
|
|
250
257
|
*/
|
|
251
258
|
async addCornerBorder(imagePath, options = {}) {
|
|
252
259
|
var _a;
|
|
253
|
-
const { borderSize = 0, color = "#000000", cornerRadius = 0, savePath, timeout } = options;
|
|
254
|
-
const response = await this.asyncCall("addCornerBorder", { imagePath, borderSize, color, cornerRadius, savePath }, timeout);
|
|
260
|
+
const { borderSize = 0, color = "#000000", cornerRadius = 0, savePath, format, timeout } = options;
|
|
261
|
+
const response = await this.asyncCall("addCornerBorder", { imagePath, borderSize, color, cornerRadius, savePath, format }, timeout);
|
|
255
262
|
if (!response.isSuccess()) {
|
|
256
263
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "添加圆角边框失败");
|
|
257
264
|
}
|
|
@@ -264,13 +271,14 @@ export class ImageUtils {
|
|
|
264
271
|
* @param options.borderSize 边框大小,默认0
|
|
265
272
|
* @param options.color 边框颜色,默认"#000000"
|
|
266
273
|
* @param options.savePath 保存路径(可选)
|
|
274
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
267
275
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
268
276
|
* @returns Promise<处理后的图片路径>
|
|
269
277
|
*/
|
|
270
278
|
async addCircleBorder(imagePath, options = {}) {
|
|
271
279
|
var _a;
|
|
272
|
-
const { borderSize = 0, color = "#000000", savePath, timeout } = options;
|
|
273
|
-
const response = await this.asyncCall("addCircleBorder", { imagePath, borderSize, color, savePath }, timeout);
|
|
280
|
+
const { borderSize = 0, color = "#000000", savePath, format, timeout } = options;
|
|
281
|
+
const response = await this.asyncCall("addCircleBorder", { imagePath, borderSize, color, savePath, format }, timeout);
|
|
274
282
|
if (!response.isSuccess()) {
|
|
275
283
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "添加圆形边框失败");
|
|
276
284
|
}
|
|
@@ -282,13 +290,14 @@ export class ImageUtils {
|
|
|
282
290
|
* @param options 选项
|
|
283
291
|
* @param options.reflectionHeight 倒影高度,默认0
|
|
284
292
|
* @param options.savePath 保存路径(可选)
|
|
293
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
285
294
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
286
295
|
* @returns Promise<处理后的图片路径>
|
|
287
296
|
*/
|
|
288
297
|
async addReflection(imagePath, options = {}) {
|
|
289
298
|
var _a;
|
|
290
|
-
const { reflectionHeight = 0, savePath, timeout } = options;
|
|
291
|
-
const response = await this.asyncCall("addReflection", { imagePath, reflectionHeight, savePath }, timeout);
|
|
299
|
+
const { reflectionHeight = 0, savePath, format, timeout } = options;
|
|
300
|
+
const response = await this.asyncCall("addReflection", { imagePath, reflectionHeight, savePath, format }, timeout);
|
|
292
301
|
if (!response.isSuccess()) {
|
|
293
302
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "添加倒影失败");
|
|
294
303
|
}
|
|
@@ -304,13 +313,14 @@ export class ImageUtils {
|
|
|
304
313
|
* @param options.color 文字颜色,默认"#000000"
|
|
305
314
|
* @param options.size 文字大小,默认16
|
|
306
315
|
* @param options.savePath 保存路径(可选)
|
|
316
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
307
317
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
308
318
|
* @returns Promise<处理后的图片路径>
|
|
309
319
|
*/
|
|
310
320
|
async addTextWatermark(imagePath, options = {}) {
|
|
311
321
|
var _a;
|
|
312
|
-
const { text = "", x = 0, y = 0, color = "#000000", size = 16, savePath, timeout } = options;
|
|
313
|
-
const response = await this.asyncCall("addTextWatermark", { imagePath, text, x, y, color, size, savePath }, timeout);
|
|
322
|
+
const { text = "", x = 0, y = 0, color = "#000000", size = 16, savePath, format, timeout } = options;
|
|
323
|
+
const response = await this.asyncCall("addTextWatermark", { imagePath, text, x, y, color, size, savePath, format }, timeout);
|
|
314
324
|
if (!response.isSuccess()) {
|
|
315
325
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "添加文字水印失败");
|
|
316
326
|
}
|
|
@@ -325,13 +335,14 @@ export class ImageUtils {
|
|
|
325
335
|
* @param options.y 水印Y坐标,默认0
|
|
326
336
|
* @param options.alpha 透明度,默认255
|
|
327
337
|
* @param options.savePath 保存路径(可选)
|
|
338
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
328
339
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
329
340
|
* @returns Promise<处理后的图片路径>
|
|
330
341
|
*/
|
|
331
342
|
async addImageWatermark(imagePath, options) {
|
|
332
343
|
var _a;
|
|
333
|
-
const { watermarkPath, x = 0, y = 0, alpha = 255, savePath, timeout } = options;
|
|
334
|
-
const response = await this.asyncCall("addImageWatermark", { imagePath, watermarkPath, x, y, alpha, savePath }, timeout);
|
|
344
|
+
const { watermarkPath, x = 0, y = 0, alpha = 255, savePath, format, timeout } = options;
|
|
345
|
+
const response = await this.asyncCall("addImageWatermark", { imagePath, watermarkPath, x, y, alpha, savePath, format }, timeout);
|
|
335
346
|
if (!response.isSuccess()) {
|
|
336
347
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "添加图片水印失败");
|
|
337
348
|
}
|
|
@@ -342,13 +353,14 @@ export class ImageUtils {
|
|
|
342
353
|
* @param imagePath 图片路径
|
|
343
354
|
* @param options 选项
|
|
344
355
|
* @param options.savePath 保存路径(可选)
|
|
356
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
345
357
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
346
358
|
* @returns Promise<处理后的图片路径>
|
|
347
359
|
*/
|
|
348
360
|
async toAlpha(imagePath, options = {}) {
|
|
349
361
|
var _a;
|
|
350
|
-
const { savePath, timeout } = options;
|
|
351
|
-
const response = await this.asyncCall("toAlpha", { imagePath, savePath }, timeout);
|
|
362
|
+
const { savePath, format, timeout } = options;
|
|
363
|
+
const response = await this.asyncCall("toAlpha", { imagePath, savePath, format }, timeout);
|
|
352
364
|
if (!response.isSuccess()) {
|
|
353
365
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "转为 alpha 位图失败");
|
|
354
366
|
}
|
|
@@ -359,13 +371,14 @@ export class ImageUtils {
|
|
|
359
371
|
* @param imagePath 图片路径
|
|
360
372
|
* @param options 选项
|
|
361
373
|
* @param options.savePath 保存路径(可选)
|
|
374
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
362
375
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
363
376
|
* @returns Promise<处理后的图片路径>
|
|
364
377
|
*/
|
|
365
378
|
async toGray(imagePath, options = {}) {
|
|
366
379
|
var _a;
|
|
367
|
-
const { savePath, timeout } = options;
|
|
368
|
-
const response = await this.asyncCall("toGray", { imagePath, savePath }, timeout);
|
|
380
|
+
const { savePath, format, timeout } = options;
|
|
381
|
+
const response = await this.asyncCall("toGray", { imagePath, savePath, format }, timeout);
|
|
369
382
|
if (!response.isSuccess()) {
|
|
370
383
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "转为灰度图片失败");
|
|
371
384
|
}
|
|
@@ -378,13 +391,14 @@ export class ImageUtils {
|
|
|
378
391
|
* @param options.radius 模糊半径,默认0
|
|
379
392
|
* @param options.scale 缩放比例,默认1
|
|
380
393
|
* @param options.savePath 保存路径(可选)
|
|
394
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
381
395
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
382
396
|
* @returns Promise<处理后的图片路径>
|
|
383
397
|
*/
|
|
384
398
|
async fastBlur(imagePath, options = {}) {
|
|
385
399
|
var _a;
|
|
386
|
-
const { radius = 0, scale = 1, savePath, timeout } = options;
|
|
387
|
-
const response = await this.asyncCall("fastBlur", { imagePath, radius, scale, savePath }, timeout);
|
|
400
|
+
const { radius = 0, scale = 1, savePath, format, timeout } = options;
|
|
401
|
+
const response = await this.asyncCall("fastBlur", { imagePath, radius, scale, savePath, format }, timeout);
|
|
388
402
|
if (!response.isSuccess()) {
|
|
389
403
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "快速模糊失败");
|
|
390
404
|
}
|
|
@@ -396,13 +410,14 @@ export class ImageUtils {
|
|
|
396
410
|
* @param options 选项
|
|
397
411
|
* @param options.radius 模糊半径,默认0
|
|
398
412
|
* @param options.savePath 保存路径(可选)
|
|
413
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
399
414
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
400
415
|
* @returns Promise<处理后的图片路径>
|
|
401
416
|
*/
|
|
402
417
|
async renderScriptBlur(imagePath, options = {}) {
|
|
403
418
|
var _a;
|
|
404
|
-
const { radius = 0, savePath, timeout } = options;
|
|
405
|
-
const response = await this.asyncCall("renderScriptBlur", { imagePath, radius, savePath }, timeout);
|
|
419
|
+
const { radius = 0, savePath, format, timeout } = options;
|
|
420
|
+
const response = await this.asyncCall("renderScriptBlur", { imagePath, radius, savePath, format }, timeout);
|
|
406
421
|
if (!response.isSuccess()) {
|
|
407
422
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "RenderScript 模糊失败");
|
|
408
423
|
}
|
|
@@ -414,13 +429,14 @@ export class ImageUtils {
|
|
|
414
429
|
* @param options 选项
|
|
415
430
|
* @param options.radius 模糊半径,默认0
|
|
416
431
|
* @param options.savePath 保存路径(可选)
|
|
432
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
417
433
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
418
434
|
* @returns Promise<处理后的图片路径>
|
|
419
435
|
*/
|
|
420
436
|
async stackBlur(imagePath, options = {}) {
|
|
421
437
|
var _a;
|
|
422
|
-
const { radius = 0, savePath, timeout } = options;
|
|
423
|
-
const response = await this.asyncCall("stackBlur", { imagePath, radius, savePath }, timeout);
|
|
438
|
+
const { radius = 0, savePath, format, timeout } = options;
|
|
439
|
+
const response = await this.asyncCall("stackBlur", { imagePath, radius, savePath, format }, timeout);
|
|
424
440
|
if (!response.isSuccess()) {
|
|
425
441
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "Stack 模糊失败");
|
|
426
442
|
}
|
|
@@ -434,13 +450,14 @@ export class ImageUtils {
|
|
|
434
450
|
* @param options.scaleWidth 缩放宽度(可选)
|
|
435
451
|
* @param options.scaleHeight 缩放高度(可选)
|
|
436
452
|
* @param options.savePath 保存路径(可选)
|
|
453
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
437
454
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
438
455
|
* @returns Promise<压缩后的图片路径>
|
|
439
456
|
*/
|
|
440
457
|
async compressByScale(imagePath, options = {}) {
|
|
441
458
|
var _a;
|
|
442
|
-
const { scaleWidth, scaleHeight, savePath, timeout } = options;
|
|
443
|
-
const response = await this.asyncCall("compressByScale", { imagePath, scaleWidth, scaleHeight, savePath }, timeout);
|
|
459
|
+
const { scaleWidth, scaleHeight, savePath, format, timeout } = options;
|
|
460
|
+
const response = await this.asyncCall("compressByScale", { imagePath, scaleWidth, scaleHeight, savePath, format }, timeout);
|
|
444
461
|
if (!response.isSuccess()) {
|
|
445
462
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "按缩放压缩失败");
|
|
446
463
|
}
|
|
@@ -471,13 +488,14 @@ export class ImageUtils {
|
|
|
471
488
|
* @param options 选项
|
|
472
489
|
* @param options.sampleSize 采样大小,默认1
|
|
473
490
|
* @param options.savePath 保存路径(可选)
|
|
491
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
474
492
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
475
493
|
* @returns Promise<压缩后的图片路径>
|
|
476
494
|
*/
|
|
477
495
|
async compressBySampleSize(imagePath, options = {}) {
|
|
478
496
|
var _a;
|
|
479
|
-
const { sampleSize = 1, savePath, timeout } = options;
|
|
480
|
-
const response = await this.asyncCall("compressBySampleSize", { imagePath, sampleSize, savePath }, timeout);
|
|
497
|
+
const { sampleSize = 1, savePath, format, timeout } = options;
|
|
498
|
+
const response = await this.asyncCall("compressBySampleSize", { imagePath, sampleSize, savePath, format }, timeout);
|
|
481
499
|
if (!response.isSuccess()) {
|
|
482
500
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "按采样大小压缩失败");
|
|
483
501
|
}
|
package/package.json
CHANGED
|
@@ -180,6 +180,7 @@ export class ImageUtils {
|
|
|
180
180
|
* @param options.scaleWidth 缩放宽度(可选)
|
|
181
181
|
* @param options.scaleHeight 缩放高度(可选)
|
|
182
182
|
* @param options.savePath 保存路径(可选)
|
|
183
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
183
184
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
184
185
|
* @returns Promise<处理后的图片路径>
|
|
185
186
|
*/
|
|
@@ -189,13 +190,14 @@ export class ImageUtils {
|
|
|
189
190
|
scaleWidth?: number;
|
|
190
191
|
scaleHeight?: number;
|
|
191
192
|
savePath?: string;
|
|
193
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
192
194
|
timeout?: number;
|
|
193
195
|
} = {}
|
|
194
196
|
): Promise<string> {
|
|
195
|
-
const { scaleWidth, scaleHeight, savePath, timeout } = options;
|
|
197
|
+
const { scaleWidth, scaleHeight, savePath, format, timeout } = options;
|
|
196
198
|
const response = await this.asyncCall(
|
|
197
199
|
"scale",
|
|
198
|
-
{ imagePath, scaleWidth, scaleHeight, savePath },
|
|
200
|
+
{ imagePath, scaleWidth, scaleHeight, savePath, format },
|
|
199
201
|
timeout
|
|
200
202
|
);
|
|
201
203
|
if (!response.isSuccess()) {
|
|
@@ -213,6 +215,7 @@ export class ImageUtils {
|
|
|
213
215
|
* @param options.width 裁剪宽度(可选,不提供则裁剪到图片右边界)
|
|
214
216
|
* @param options.height 裁剪高度(可选,不提供则裁剪到图片下边界)
|
|
215
217
|
* @param options.savePath 保存路径(可选)
|
|
218
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
216
219
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
217
220
|
* @returns Promise<处理后的图片路径>
|
|
218
221
|
*/
|
|
@@ -224,13 +227,14 @@ export class ImageUtils {
|
|
|
224
227
|
width?: number;
|
|
225
228
|
height?: number;
|
|
226
229
|
savePath?: string;
|
|
230
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
227
231
|
timeout?: number;
|
|
228
232
|
} = {}
|
|
229
233
|
): Promise<string> {
|
|
230
|
-
const { x = 0, y = 0, width, height, savePath, timeout } = options;
|
|
234
|
+
const { x = 0, y = 0, width, height, savePath, format, timeout } = options;
|
|
231
235
|
const response = await this.asyncCall(
|
|
232
236
|
"clip",
|
|
233
|
-
{ imagePath, x, y, width, height, savePath },
|
|
237
|
+
{ imagePath, x, y, width, height, savePath, format },
|
|
234
238
|
timeout
|
|
235
239
|
);
|
|
236
240
|
if (!response.isSuccess()) {
|
|
@@ -248,6 +252,7 @@ export class ImageUtils {
|
|
|
248
252
|
* @param options.px X轴倾斜点(可选)
|
|
249
253
|
* @param options.py Y轴倾斜点(可选)
|
|
250
254
|
* @param options.savePath 保存路径(可选)
|
|
255
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
251
256
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
252
257
|
* @returns Promise<处理后的图片路径>
|
|
253
258
|
*/
|
|
@@ -259,13 +264,14 @@ export class ImageUtils {
|
|
|
259
264
|
px?: number;
|
|
260
265
|
py?: number;
|
|
261
266
|
savePath?: string;
|
|
267
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
262
268
|
timeout?: number;
|
|
263
269
|
} = {}
|
|
264
270
|
): Promise<string> {
|
|
265
|
-
const { kx = 0, ky = 0, px, py, savePath, timeout } = options;
|
|
271
|
+
const { kx = 0, ky = 0, px, py, savePath, format, timeout } = options;
|
|
266
272
|
const response = await this.asyncCall(
|
|
267
273
|
"skew",
|
|
268
|
-
{ imagePath, kx, ky, px, py, savePath },
|
|
274
|
+
{ imagePath, kx, ky, px, py, savePath, format },
|
|
269
275
|
timeout
|
|
270
276
|
);
|
|
271
277
|
if (!response.isSuccess()) {
|
|
@@ -282,6 +288,7 @@ export class ImageUtils {
|
|
|
282
288
|
* @param options.px 旋转中心X坐标(可选)
|
|
283
289
|
* @param options.py 旋转中心Y坐标(可选)
|
|
284
290
|
* @param options.savePath 保存路径(可选)
|
|
291
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
285
292
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
286
293
|
* @returns Promise<处理后的图片路径>
|
|
287
294
|
*/
|
|
@@ -292,13 +299,14 @@ export class ImageUtils {
|
|
|
292
299
|
px?: number;
|
|
293
300
|
py?: number;
|
|
294
301
|
savePath?: string;
|
|
302
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
295
303
|
timeout?: number;
|
|
296
304
|
} = {}
|
|
297
305
|
): Promise<string> {
|
|
298
|
-
const { degree = 0, px, py, savePath, timeout } = options;
|
|
306
|
+
const { degree = 0, px, py, savePath, format, timeout } = options;
|
|
299
307
|
const response = await this.asyncCall(
|
|
300
308
|
"rotate",
|
|
301
|
-
{ imagePath, degree, px, py, savePath },
|
|
309
|
+
{ imagePath, degree, px, py, savePath, format },
|
|
302
310
|
timeout
|
|
303
311
|
);
|
|
304
312
|
if (!response.isSuccess()) {
|
|
@@ -312,6 +320,7 @@ export class ImageUtils {
|
|
|
312
320
|
* @param imagePath 图片路径
|
|
313
321
|
* @param options 选项
|
|
314
322
|
* @param options.savePath 保存路径(可选)
|
|
323
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
315
324
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
316
325
|
* @returns Promise<处理后的图片路径>
|
|
317
326
|
*/
|
|
@@ -319,13 +328,14 @@ export class ImageUtils {
|
|
|
319
328
|
imagePath: string,
|
|
320
329
|
options: {
|
|
321
330
|
savePath?: string;
|
|
331
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
322
332
|
timeout?: number;
|
|
323
333
|
} = {}
|
|
324
334
|
): Promise<string> {
|
|
325
|
-
const { savePath, timeout } = options;
|
|
335
|
+
const { savePath, format, timeout } = options;
|
|
326
336
|
const response = await this.asyncCall(
|
|
327
337
|
"toRound",
|
|
328
|
-
{ imagePath, savePath },
|
|
338
|
+
{ imagePath, savePath, format },
|
|
329
339
|
timeout
|
|
330
340
|
);
|
|
331
341
|
if (!response.isSuccess()) {
|
|
@@ -340,6 +350,7 @@ export class ImageUtils {
|
|
|
340
350
|
* @param options 选项
|
|
341
351
|
* @param options.radius 圆角半径,默认0
|
|
342
352
|
* @param options.savePath 保存路径(可选)
|
|
353
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
343
354
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
344
355
|
* @returns Promise<处理后的图片路径>
|
|
345
356
|
*/
|
|
@@ -348,13 +359,14 @@ export class ImageUtils {
|
|
|
348
359
|
options: {
|
|
349
360
|
radius?: number;
|
|
350
361
|
savePath?: string;
|
|
362
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
351
363
|
timeout?: number;
|
|
352
364
|
} = {}
|
|
353
365
|
): Promise<string> {
|
|
354
|
-
const { radius = 0, savePath, timeout } = options;
|
|
366
|
+
const { radius = 0, savePath, format, timeout } = options;
|
|
355
367
|
const response = await this.asyncCall(
|
|
356
368
|
"toRoundCorner",
|
|
357
|
-
{ imagePath, radius, savePath },
|
|
369
|
+
{ imagePath, radius, savePath, format },
|
|
358
370
|
timeout
|
|
359
371
|
);
|
|
360
372
|
if (!response.isSuccess()) {
|
|
@@ -371,6 +383,7 @@ export class ImageUtils {
|
|
|
371
383
|
* @param options.color 边框颜色,默认"#000000"
|
|
372
384
|
* @param options.cornerRadius 圆角半径,默认0
|
|
373
385
|
* @param options.savePath 保存路径(可选)
|
|
386
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
374
387
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
375
388
|
* @returns Promise<处理后的图片路径>
|
|
376
389
|
*/
|
|
@@ -381,13 +394,14 @@ export class ImageUtils {
|
|
|
381
394
|
color?: string;
|
|
382
395
|
cornerRadius?: number;
|
|
383
396
|
savePath?: string;
|
|
397
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
384
398
|
timeout?: number;
|
|
385
399
|
} = {}
|
|
386
400
|
): Promise<string> {
|
|
387
|
-
const { borderSize = 0, color = "#000000", cornerRadius = 0, savePath, timeout } = options;
|
|
401
|
+
const { borderSize = 0, color = "#000000", cornerRadius = 0, savePath, format, timeout } = options;
|
|
388
402
|
const response = await this.asyncCall(
|
|
389
403
|
"addCornerBorder",
|
|
390
|
-
{ imagePath, borderSize, color, cornerRadius, savePath },
|
|
404
|
+
{ imagePath, borderSize, color, cornerRadius, savePath, format },
|
|
391
405
|
timeout
|
|
392
406
|
);
|
|
393
407
|
if (!response.isSuccess()) {
|
|
@@ -403,6 +417,7 @@ export class ImageUtils {
|
|
|
403
417
|
* @param options.borderSize 边框大小,默认0
|
|
404
418
|
* @param options.color 边框颜色,默认"#000000"
|
|
405
419
|
* @param options.savePath 保存路径(可选)
|
|
420
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
406
421
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
407
422
|
* @returns Promise<处理后的图片路径>
|
|
408
423
|
*/
|
|
@@ -412,13 +427,14 @@ export class ImageUtils {
|
|
|
412
427
|
borderSize?: number;
|
|
413
428
|
color?: string;
|
|
414
429
|
savePath?: string;
|
|
430
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
415
431
|
timeout?: number;
|
|
416
432
|
} = {}
|
|
417
433
|
): Promise<string> {
|
|
418
|
-
const { borderSize = 0, color = "#000000", savePath, timeout } = options;
|
|
434
|
+
const { borderSize = 0, color = "#000000", savePath, format, timeout } = options;
|
|
419
435
|
const response = await this.asyncCall(
|
|
420
436
|
"addCircleBorder",
|
|
421
|
-
{ imagePath, borderSize, color, savePath },
|
|
437
|
+
{ imagePath, borderSize, color, savePath, format },
|
|
422
438
|
timeout
|
|
423
439
|
);
|
|
424
440
|
if (!response.isSuccess()) {
|
|
@@ -433,6 +449,7 @@ export class ImageUtils {
|
|
|
433
449
|
* @param options 选项
|
|
434
450
|
* @param options.reflectionHeight 倒影高度,默认0
|
|
435
451
|
* @param options.savePath 保存路径(可选)
|
|
452
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
436
453
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
437
454
|
* @returns Promise<处理后的图片路径>
|
|
438
455
|
*/
|
|
@@ -441,13 +458,14 @@ export class ImageUtils {
|
|
|
441
458
|
options: {
|
|
442
459
|
reflectionHeight?: number;
|
|
443
460
|
savePath?: string;
|
|
461
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
444
462
|
timeout?: number;
|
|
445
463
|
} = {}
|
|
446
464
|
): Promise<string> {
|
|
447
|
-
const { reflectionHeight = 0, savePath, timeout } = options;
|
|
465
|
+
const { reflectionHeight = 0, savePath, format, timeout } = options;
|
|
448
466
|
const response = await this.asyncCall(
|
|
449
467
|
"addReflection",
|
|
450
|
-
{ imagePath, reflectionHeight, savePath },
|
|
468
|
+
{ imagePath, reflectionHeight, savePath, format },
|
|
451
469
|
timeout
|
|
452
470
|
);
|
|
453
471
|
if (!response.isSuccess()) {
|
|
@@ -466,6 +484,7 @@ export class ImageUtils {
|
|
|
466
484
|
* @param options.color 文字颜色,默认"#000000"
|
|
467
485
|
* @param options.size 文字大小,默认16
|
|
468
486
|
* @param options.savePath 保存路径(可选)
|
|
487
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
469
488
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
470
489
|
* @returns Promise<处理后的图片路径>
|
|
471
490
|
*/
|
|
@@ -478,13 +497,14 @@ export class ImageUtils {
|
|
|
478
497
|
color?: string;
|
|
479
498
|
size?: number;
|
|
480
499
|
savePath?: string;
|
|
500
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
481
501
|
timeout?: number;
|
|
482
502
|
} = {}
|
|
483
503
|
): Promise<string> {
|
|
484
|
-
const { text = "", x = 0, y = 0, color = "#000000", size = 16, savePath, timeout } = options;
|
|
504
|
+
const { text = "", x = 0, y = 0, color = "#000000", size = 16, savePath, format, timeout } = options;
|
|
485
505
|
const response = await this.asyncCall(
|
|
486
506
|
"addTextWatermark",
|
|
487
|
-
{ imagePath, text, x, y, color, size, savePath },
|
|
507
|
+
{ imagePath, text, x, y, color, size, savePath, format },
|
|
488
508
|
timeout
|
|
489
509
|
);
|
|
490
510
|
if (!response.isSuccess()) {
|
|
@@ -502,6 +522,7 @@ export class ImageUtils {
|
|
|
502
522
|
* @param options.y 水印Y坐标,默认0
|
|
503
523
|
* @param options.alpha 透明度,默认255
|
|
504
524
|
* @param options.savePath 保存路径(可选)
|
|
525
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
505
526
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
506
527
|
* @returns Promise<处理后的图片路径>
|
|
507
528
|
*/
|
|
@@ -513,13 +534,14 @@ export class ImageUtils {
|
|
|
513
534
|
y?: number;
|
|
514
535
|
alpha?: number;
|
|
515
536
|
savePath?: string;
|
|
537
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
516
538
|
timeout?: number;
|
|
517
539
|
}
|
|
518
540
|
): Promise<string> {
|
|
519
|
-
const { watermarkPath, x = 0, y = 0, alpha = 255, savePath, timeout } = options;
|
|
541
|
+
const { watermarkPath, x = 0, y = 0, alpha = 255, savePath, format, timeout } = options;
|
|
520
542
|
const response = await this.asyncCall(
|
|
521
543
|
"addImageWatermark",
|
|
522
|
-
{ imagePath, watermarkPath, x, y, alpha, savePath },
|
|
544
|
+
{ imagePath, watermarkPath, x, y, alpha, savePath, format },
|
|
523
545
|
timeout
|
|
524
546
|
);
|
|
525
547
|
if (!response.isSuccess()) {
|
|
@@ -533,6 +555,7 @@ export class ImageUtils {
|
|
|
533
555
|
* @param imagePath 图片路径
|
|
534
556
|
* @param options 选项
|
|
535
557
|
* @param options.savePath 保存路径(可选)
|
|
558
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
536
559
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
537
560
|
* @returns Promise<处理后的图片路径>
|
|
538
561
|
*/
|
|
@@ -540,13 +563,14 @@ export class ImageUtils {
|
|
|
540
563
|
imagePath: string,
|
|
541
564
|
options: {
|
|
542
565
|
savePath?: string;
|
|
566
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
543
567
|
timeout?: number;
|
|
544
568
|
} = {}
|
|
545
569
|
): Promise<string> {
|
|
546
|
-
const { savePath, timeout } = options;
|
|
570
|
+
const { savePath, format, timeout } = options;
|
|
547
571
|
const response = await this.asyncCall(
|
|
548
572
|
"toAlpha",
|
|
549
|
-
{ imagePath, savePath },
|
|
573
|
+
{ imagePath, savePath, format },
|
|
550
574
|
timeout
|
|
551
575
|
);
|
|
552
576
|
if (!response.isSuccess()) {
|
|
@@ -560,6 +584,7 @@ export class ImageUtils {
|
|
|
560
584
|
* @param imagePath 图片路径
|
|
561
585
|
* @param options 选项
|
|
562
586
|
* @param options.savePath 保存路径(可选)
|
|
587
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
563
588
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
564
589
|
* @returns Promise<处理后的图片路径>
|
|
565
590
|
*/
|
|
@@ -567,13 +592,14 @@ export class ImageUtils {
|
|
|
567
592
|
imagePath: string,
|
|
568
593
|
options: {
|
|
569
594
|
savePath?: string;
|
|
595
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
570
596
|
timeout?: number;
|
|
571
597
|
} = {}
|
|
572
598
|
): Promise<string> {
|
|
573
|
-
const { savePath, timeout } = options;
|
|
599
|
+
const { savePath, format, timeout } = options;
|
|
574
600
|
const response = await this.asyncCall(
|
|
575
601
|
"toGray",
|
|
576
|
-
{ imagePath, savePath },
|
|
602
|
+
{ imagePath, savePath, format },
|
|
577
603
|
timeout
|
|
578
604
|
);
|
|
579
605
|
if (!response.isSuccess()) {
|
|
@@ -589,6 +615,7 @@ export class ImageUtils {
|
|
|
589
615
|
* @param options.radius 模糊半径,默认0
|
|
590
616
|
* @param options.scale 缩放比例,默认1
|
|
591
617
|
* @param options.savePath 保存路径(可选)
|
|
618
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
592
619
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
593
620
|
* @returns Promise<处理后的图片路径>
|
|
594
621
|
*/
|
|
@@ -598,13 +625,14 @@ export class ImageUtils {
|
|
|
598
625
|
radius?: number;
|
|
599
626
|
scale?: number;
|
|
600
627
|
savePath?: string;
|
|
628
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
601
629
|
timeout?: number;
|
|
602
630
|
} = {}
|
|
603
631
|
): Promise<string> {
|
|
604
|
-
const { radius = 0, scale = 1, savePath, timeout } = options;
|
|
632
|
+
const { radius = 0, scale = 1, savePath, format, timeout } = options;
|
|
605
633
|
const response = await this.asyncCall(
|
|
606
634
|
"fastBlur",
|
|
607
|
-
{ imagePath, radius, scale, savePath },
|
|
635
|
+
{ imagePath, radius, scale, savePath, format },
|
|
608
636
|
timeout
|
|
609
637
|
);
|
|
610
638
|
if (!response.isSuccess()) {
|
|
@@ -619,6 +647,7 @@ export class ImageUtils {
|
|
|
619
647
|
* @param options 选项
|
|
620
648
|
* @param options.radius 模糊半径,默认0
|
|
621
649
|
* @param options.savePath 保存路径(可选)
|
|
650
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
622
651
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
623
652
|
* @returns Promise<处理后的图片路径>
|
|
624
653
|
*/
|
|
@@ -627,13 +656,14 @@ export class ImageUtils {
|
|
|
627
656
|
options: {
|
|
628
657
|
radius?: number;
|
|
629
658
|
savePath?: string;
|
|
659
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
630
660
|
timeout?: number;
|
|
631
661
|
} = {}
|
|
632
662
|
): Promise<string> {
|
|
633
|
-
const { radius = 0, savePath, timeout } = options;
|
|
663
|
+
const { radius = 0, savePath, format, timeout } = options;
|
|
634
664
|
const response = await this.asyncCall(
|
|
635
665
|
"renderScriptBlur",
|
|
636
|
-
{ imagePath, radius, savePath },
|
|
666
|
+
{ imagePath, radius, savePath, format },
|
|
637
667
|
timeout
|
|
638
668
|
);
|
|
639
669
|
if (!response.isSuccess()) {
|
|
@@ -648,6 +678,7 @@ export class ImageUtils {
|
|
|
648
678
|
* @param options 选项
|
|
649
679
|
* @param options.radius 模糊半径,默认0
|
|
650
680
|
* @param options.savePath 保存路径(可选)
|
|
681
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
651
682
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
652
683
|
* @returns Promise<处理后的图片路径>
|
|
653
684
|
*/
|
|
@@ -656,13 +687,14 @@ export class ImageUtils {
|
|
|
656
687
|
options: {
|
|
657
688
|
radius?: number;
|
|
658
689
|
savePath?: string;
|
|
690
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
659
691
|
timeout?: number;
|
|
660
692
|
} = {}
|
|
661
693
|
): Promise<string> {
|
|
662
|
-
const { radius = 0, savePath, timeout } = options;
|
|
694
|
+
const { radius = 0, savePath, format, timeout } = options;
|
|
663
695
|
const response = await this.asyncCall(
|
|
664
696
|
"stackBlur",
|
|
665
|
-
{ imagePath, radius, savePath },
|
|
697
|
+
{ imagePath, radius, savePath, format },
|
|
666
698
|
timeout
|
|
667
699
|
);
|
|
668
700
|
if (!response.isSuccess()) {
|
|
@@ -680,6 +712,7 @@ export class ImageUtils {
|
|
|
680
712
|
* @param options.scaleWidth 缩放宽度(可选)
|
|
681
713
|
* @param options.scaleHeight 缩放高度(可选)
|
|
682
714
|
* @param options.savePath 保存路径(可选)
|
|
715
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
683
716
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
684
717
|
* @returns Promise<压缩后的图片路径>
|
|
685
718
|
*/
|
|
@@ -689,13 +722,14 @@ export class ImageUtils {
|
|
|
689
722
|
scaleWidth?: number;
|
|
690
723
|
scaleHeight?: number;
|
|
691
724
|
savePath?: string;
|
|
725
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
692
726
|
timeout?: number;
|
|
693
727
|
} = {}
|
|
694
728
|
): Promise<string> {
|
|
695
|
-
const { scaleWidth, scaleHeight, savePath, timeout } = options;
|
|
729
|
+
const { scaleWidth, scaleHeight, savePath, format, timeout } = options;
|
|
696
730
|
const response = await this.asyncCall(
|
|
697
731
|
"compressByScale",
|
|
698
|
-
{ imagePath, scaleWidth, scaleHeight, savePath },
|
|
732
|
+
{ imagePath, scaleWidth, scaleHeight, savePath, format },
|
|
699
733
|
timeout
|
|
700
734
|
);
|
|
701
735
|
if (!response.isSuccess()) {
|
|
@@ -741,6 +775,7 @@ export class ImageUtils {
|
|
|
741
775
|
* @param options 选项
|
|
742
776
|
* @param options.sampleSize 采样大小,默认1
|
|
743
777
|
* @param options.savePath 保存路径(可选)
|
|
778
|
+
* @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认"PNG"
|
|
744
779
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
745
780
|
* @returns Promise<压缩后的图片路径>
|
|
746
781
|
*/
|
|
@@ -749,13 +784,14 @@ export class ImageUtils {
|
|
|
749
784
|
options: {
|
|
750
785
|
sampleSize?: number;
|
|
751
786
|
savePath?: string;
|
|
787
|
+
format?: "PNG" | "JPEG" | "JPG" | "WEBP";
|
|
752
788
|
timeout?: number;
|
|
753
789
|
} = {}
|
|
754
790
|
): Promise<string> {
|
|
755
|
-
const { sampleSize = 1, savePath, timeout } = options;
|
|
791
|
+
const { sampleSize = 1, savePath, format, timeout } = options;
|
|
756
792
|
const response = await this.asyncCall(
|
|
757
793
|
"compressBySampleSize",
|
|
758
|
-
{ imagePath, sampleSize, savePath },
|
|
794
|
+
{ imagePath, sampleSize, savePath, format },
|
|
759
795
|
timeout
|
|
760
796
|
);
|
|
761
797
|
if (!response.isSuccess()) {
|