@image-marker/web 0.1.0
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 +11 -0
- package/README.md +100 -0
- package/api-contract.json +224 -0
- package/lib/commonjs/core/batch.d.ts +32 -0
- package/lib/commonjs/core/batch.js +85 -0
- package/lib/commonjs/core/content-credentials.d.ts +53 -0
- package/lib/commonjs/core/content-credentials.js +96 -0
- package/lib/commonjs/core/image-info.d.ts +30 -0
- package/lib/commonjs/core/image-info.js +348 -0
- package/lib/commonjs/core/index.d.ts +1014 -0
- package/lib/commonjs/core/index.js +92 -0
- package/lib/commonjs/core/invisible-watermark.d.ts +102 -0
- package/lib/commonjs/core/invisible-watermark.js +913 -0
- package/lib/commonjs/core/job.d.ts +57 -0
- package/lib/commonjs/core/job.js +151 -0
- package/lib/commonjs/core/layout.d.ts +19 -0
- package/lib/commonjs/core/layout.js +75 -0
- package/lib/commonjs/core/marker.d.ts +1 -0
- package/lib/commonjs/core/marker.js +11 -0
- package/lib/commonjs/core/recipe.d.ts +44 -0
- package/lib/commonjs/core/recipe.js +175 -0
- package/lib/commonjs/core/result.d.ts +34 -0
- package/lib/commonjs/core/result.js +41 -0
- package/lib/commonjs/core/trace-runtime.d.ts +43 -0
- package/lib/commonjs/core/trace-runtime.js +92 -0
- package/lib/commonjs/core/validate.d.ts +4 -0
- package/lib/commonjs/core/validate.js +192 -0
- package/lib/commonjs/core/web/browser.d.ts +105 -0
- package/lib/commonjs/core/web/browser.js +434 -0
- package/lib/commonjs/core/web/helpers.d.ts +41 -0
- package/lib/commonjs/core/web/helpers.js +264 -0
- package/lib/commonjs/core/web/index.d.ts +59 -0
- package/lib/commonjs/core/web/index.js +724 -0
- package/lib/commonjs/core/web/invisible-worker-client.d.ts +13 -0
- package/lib/commonjs/core/web/invisible-worker-client.js +140 -0
- package/lib/commonjs/core/web/renderer.d.ts +20 -0
- package/lib/commonjs/core/web/renderer.js +665 -0
- package/lib/commonjs/core/web/runtime.d.ts +106 -0
- package/lib/commonjs/core/web/runtime.js +2 -0
- package/lib/commonjs/editor/adapter.d.ts +26 -0
- package/lib/commonjs/editor/adapter.js +102 -0
- package/lib/commonjs/editor/controller.d.ts +106 -0
- package/lib/commonjs/editor/controller.js +919 -0
- package/lib/commonjs/editor/core-contract.d.ts +2 -0
- package/lib/commonjs/editor/core-contract.js +23 -0
- package/lib/commonjs/editor/geometry.d.ts +8 -0
- package/lib/commonjs/editor/geometry.js +109 -0
- package/lib/commonjs/editor/headless.d.ts +5 -0
- package/lib/commonjs/editor/headless.js +22 -0
- package/lib/commonjs/editor/presets.d.ts +19 -0
- package/lib/commonjs/editor/presets.js +64 -0
- package/lib/commonjs/editor/projection.d.ts +12 -0
- package/lib/commonjs/editor/projection.js +195 -0
- package/lib/commonjs/editor/types.d.ts +166 -0
- package/lib/commonjs/editor/types.js +2 -0
- package/lib/commonjs/editor-adapter.d.ts +7 -0
- package/lib/commonjs/editor-adapter.js +17 -0
- package/lib/commonjs/headless.d.ts +2 -0
- package/lib/commonjs/headless.js +26 -0
- package/lib/commonjs/index.d.ts +5 -0
- package/lib/commonjs/index.js +27 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/core/batch.d.ts +32 -0
- package/lib/module/core/batch.js +82 -0
- package/lib/module/core/content-credentials.d.ts +53 -0
- package/lib/module/core/content-credentials.js +92 -0
- package/lib/module/core/image-info.d.ts +30 -0
- package/lib/module/core/image-info.js +343 -0
- package/lib/module/core/index.d.ts +1014 -0
- package/lib/module/core/index.js +56 -0
- package/lib/module/core/invisible-watermark.d.ts +102 -0
- package/lib/module/core/invisible-watermark.js +897 -0
- package/lib/module/core/job.d.ts +57 -0
- package/lib/module/core/job.js +143 -0
- package/lib/module/core/layout.d.ts +19 -0
- package/lib/module/core/layout.js +70 -0
- package/lib/module/core/marker.d.ts +1 -0
- package/lib/module/core/marker.js +4 -0
- package/lib/module/core/recipe.d.ts +44 -0
- package/lib/module/core/recipe.js +169 -0
- package/lib/module/core/result.d.ts +34 -0
- package/lib/module/core/result.js +38 -0
- package/lib/module/core/trace-runtime.d.ts +43 -0
- package/lib/module/core/trace-runtime.js +89 -0
- package/lib/module/core/validate.d.ts +4 -0
- package/lib/module/core/validate.js +187 -0
- package/lib/module/core/web/browser.d.ts +105 -0
- package/lib/module/core/web/browser.js +427 -0
- package/lib/module/core/web/helpers.d.ts +41 -0
- package/lib/module/core/web/helpers.js +251 -0
- package/lib/module/core/web/index.d.ts +59 -0
- package/lib/module/core/web/index.js +709 -0
- package/lib/module/core/web/invisible-worker-client.d.ts +13 -0
- package/lib/module/core/web/invisible-worker-client.js +137 -0
- package/lib/module/core/web/renderer.d.ts +20 -0
- package/lib/module/core/web/renderer.js +661 -0
- package/lib/module/core/web/runtime.d.ts +106 -0
- package/lib/module/core/web/runtime.js +1 -0
- package/lib/module/editor/adapter.d.ts +26 -0
- package/lib/module/editor/adapter.js +99 -0
- package/lib/module/editor/controller.d.ts +106 -0
- package/lib/module/editor/controller.js +915 -0
- package/lib/module/editor/core-contract.d.ts +2 -0
- package/lib/module/editor/core-contract.js +2 -0
- package/lib/module/editor/geometry.d.ts +8 -0
- package/lib/module/editor/geometry.js +103 -0
- package/lib/module/editor/headless.d.ts +5 -0
- package/lib/module/editor/headless.js +4 -0
- package/lib/module/editor/presets.d.ts +19 -0
- package/lib/module/editor/presets.js +57 -0
- package/lib/module/editor/projection.d.ts +12 -0
- package/lib/module/editor/projection.js +188 -0
- package/lib/module/editor/types.d.ts +166 -0
- package/lib/module/editor/types.js +1 -0
- package/lib/module/editor-adapter.d.ts +7 -0
- package/lib/module/editor-adapter.js +10 -0
- package/lib/module/headless.d.ts +2 -0
- package/lib/module/headless.js +2 -0
- package/lib/module/index.d.ts +5 -0
- package/lib/module/index.js +3 -0
- package/lib/module/package.json +1 -0
- package/lib/source-manifest.json +34 -0
- package/lib/worker/invisible-watermark.js +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,1014 @@
|
|
|
1
|
+
import Marker from './marker.js';
|
|
2
|
+
export type { ImageOrientation, MarkerImageFormat, MarkerImageInfo, } from './image-info.js';
|
|
3
|
+
export { parseEncodedImageInfo } from './image-info.js';
|
|
4
|
+
export type { MarkerOperation, MarkerOutputFormat, MarkerMetadataResult, MarkerResult, MarkerResultDescriptor, } from './result.js';
|
|
5
|
+
export type { ImageMarkerErrorCode, MarkerJobOptions, MarkerJobPhase, MarkerJobProgress, } from './job.js';
|
|
6
|
+
export { ImageMarkerError } from './job.js';
|
|
7
|
+
export type { WatermarkBatchAbortedResult, WatermarkBatchFulfilledResult, WatermarkBatchOptions, WatermarkBatchProgress, WatermarkBatchRejectedResult, WatermarkBatchResult, LegacyWatermarkRecipeDefinition, WatermarkRecipe, WatermarkBlobRecipeResultOptions, WatermarkRecipeCondition, WatermarkRecipeDefinition, WatermarkRecipeDefinitionLayer, WatermarkRecipeDocument, WatermarkRecipeInput, WatermarkRecipeLayer, WatermarkMarkerResultRecipeOptions, WatermarkRecipeOptions, WatermarkRecipeOutputOptions, WatermarkRecipeResultOptions, WatermarkRecipeSchemaVersion, WatermarkRecipeVariable, } from './recipe.js';
|
|
8
|
+
export { migrateWatermarkRecipe, WATERMARK_RECIPE_SCHEMA_VERSION, } from './recipe.js';
|
|
9
|
+
export { addWatermarkRecipeLayer, cloneRecipeValue, cloneWatermarkRecipe, cloneWatermarkRecipeLayer, createWatermarkRecipeDefinition, duplicateWatermarkRecipeLayer, groupWatermarkRecipeLayers, materializeWatermarkRecipe, parseWatermarkRecipe, recipeValidationPatterns, removeWatermarkRecipeLayer, reorderWatermarkRecipeLayer, resolveWatermarkTemplate, safeValidateWatermarkRecipe, serializeWatermarkRecipe, ungroupWatermarkRecipeLayers, updateWatermarkRecipeLayer, validateWatermarkRecipe, validateWatermarkTemplate, WatermarkRecipeValidationError, } from '@image-marker/recipe';
|
|
10
|
+
export type { WatermarkRecipeValidationFailure, WatermarkRecipeValidationResult, WatermarkRecipeValidationSuccess, WatermarkRecipeVariableContext, WatermarkTextDirection, WatermarkTextOverflow, WatermarkTextWrap, } from '@image-marker/recipe';
|
|
11
|
+
export type { DetectInvisibleWatermarkOptions, EmbedInvisibleWatermarkOptions, InvisibleWatermarkDetectionData, InvisibleWatermarkDetectionResult, InvisibleWatermarkImage, InvisibleWatermarkSearch, InvisibleWatermarkStrength, InvisibleWatermarkWorkerOptions, InvisibleWatermarkWorkerProgressPhase, } from './invisible-watermark.js';
|
|
12
|
+
export { INVISIBLE_WATERMARK_ALGORITHM, INVISIBLE_WATERMARK_MAX_PAYLOAD_BYTES, INVISIBLE_WATERMARK_MIN_HEIGHT, INVISIBLE_WATERMARK_MIN_KEY_BYTES, INVISIBLE_WATERMARK_MIN_WIDTH, INVISIBLE_WATERMARK_RESIZE_SCALES, } from './invisible-watermark.js';
|
|
13
|
+
export type { InvisibleWatermarkCodec, InvisibleWatermarkDecodedImage, InvisibleWatermarkRuntime, InvisibleWatermarkRuntimeOptions, RuntimeDetectInvisibleWatermarkOptions, RuntimeEmbedInvisibleWatermarkOptions, } from './trace-runtime.js';
|
|
14
|
+
export type { ContentCredentialsAdapter, ContentCredentialsClaim, ContentCredentialsSignRequest, ContentCredentialsSignResult, ContentCredentialsVerificationResult, EmbedInvisibleWithCredentialsOptions, EmbedInvisibleWithCredentialsResult, VerifyContentCredentialsOptions, } from './content-credentials.js';
|
|
15
|
+
/**
|
|
16
|
+
* Position enum for text watermark and image watermark
|
|
17
|
+
* @enum
|
|
18
|
+
*/
|
|
19
|
+
export declare enum Position {
|
|
20
|
+
topLeft = "topLeft",
|
|
21
|
+
topCenter = "topCenter",
|
|
22
|
+
topRight = "topRight",
|
|
23
|
+
bottomLeft = "bottomLeft",
|
|
24
|
+
bottomCenter = "bottomCenter",
|
|
25
|
+
bottomRight = "bottomRight",
|
|
26
|
+
center = "center"
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* TextBackgroundType enum for text watermark
|
|
30
|
+
* @enum
|
|
31
|
+
*/
|
|
32
|
+
export declare enum TextBackgroundType {
|
|
33
|
+
stretchX = "stretchX",
|
|
34
|
+
stretchY = "stretchY",
|
|
35
|
+
none = "fit"
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* ImageFormat enum for save image format
|
|
39
|
+
* @enum
|
|
40
|
+
*/
|
|
41
|
+
export declare enum ImageFormat {
|
|
42
|
+
png = "png",
|
|
43
|
+
jpg = "jpg",
|
|
44
|
+
/** WebP output on Android and compatible browsers. iOS rejects it explicitly. */
|
|
45
|
+
webp = "webp",
|
|
46
|
+
base64 = "base64"
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Controls the output canvas after the composed image is rotated.
|
|
50
|
+
*
|
|
51
|
+
* `expand` preserves the entire rotated image by growing the output canvas.
|
|
52
|
+
* `crop` keeps the original canvas dimensions and clips content outside it.
|
|
53
|
+
* @enum
|
|
54
|
+
*/
|
|
55
|
+
export declare enum RotationCanvasMode {
|
|
56
|
+
expand = "expand",
|
|
57
|
+
crop = "crop"
|
|
58
|
+
}
|
|
59
|
+
/** Cross-platform compositing modes supported by text and image watermarks. */
|
|
60
|
+
export type BlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten';
|
|
61
|
+
/**
|
|
62
|
+
* Padding style for text background
|
|
63
|
+
* @example
|
|
64
|
+
* padding: 10
|
|
65
|
+
* // or
|
|
66
|
+
* padding: '10%'
|
|
67
|
+
* // or
|
|
68
|
+
* padding: '10% 20%'
|
|
69
|
+
* // or
|
|
70
|
+
* padding: '10% 20% 30%'
|
|
71
|
+
* // or
|
|
72
|
+
* paddingLeft: '10%'
|
|
73
|
+
* // or
|
|
74
|
+
* paddingVertical: '10%'
|
|
75
|
+
*/
|
|
76
|
+
interface Padding {
|
|
77
|
+
/**
|
|
78
|
+
* padding for text background
|
|
79
|
+
* @example
|
|
80
|
+
* padding: 10
|
|
81
|
+
* // or
|
|
82
|
+
* padding: '10%'
|
|
83
|
+
* // or
|
|
84
|
+
* padding: '10% 20%'
|
|
85
|
+
* // or
|
|
86
|
+
* padding: '10% 20% 30%'
|
|
87
|
+
* // or
|
|
88
|
+
* padding: '10% 20% 30% 40%'
|
|
89
|
+
* // or
|
|
90
|
+
* padding: '10 20% 30 40%'
|
|
91
|
+
* // or
|
|
92
|
+
* padding: '10 20 30'
|
|
93
|
+
*/
|
|
94
|
+
padding?: number | string;
|
|
95
|
+
/**
|
|
96
|
+
* padding left for text background
|
|
97
|
+
* @example
|
|
98
|
+
* paddingLeft: 10
|
|
99
|
+
* // or
|
|
100
|
+
* paddingLeft: '10%'
|
|
101
|
+
*/
|
|
102
|
+
paddingLeft?: number | string;
|
|
103
|
+
/**
|
|
104
|
+
* padding right for text background
|
|
105
|
+
* @example
|
|
106
|
+
* paddingRight: 10
|
|
107
|
+
* // or
|
|
108
|
+
* paddingRight: '10%'
|
|
109
|
+
*/
|
|
110
|
+
paddingRight?: number | string;
|
|
111
|
+
/**
|
|
112
|
+
* padding top for text background
|
|
113
|
+
* @example
|
|
114
|
+
* paddingTop: 10
|
|
115
|
+
* // or
|
|
116
|
+
* paddingTop: '10%'
|
|
117
|
+
*/
|
|
118
|
+
paddingTop?: number | string;
|
|
119
|
+
/**
|
|
120
|
+
* padding bottom for text background
|
|
121
|
+
* @example
|
|
122
|
+
* paddingBottom: 10
|
|
123
|
+
* // or
|
|
124
|
+
* paddingBottom: '10%'
|
|
125
|
+
*/
|
|
126
|
+
paddingBottom?: number | string;
|
|
127
|
+
/**
|
|
128
|
+
* padding left and right (horizontal) for text background
|
|
129
|
+
* @example
|
|
130
|
+
* paddingHorizontal: 10
|
|
131
|
+
* // or
|
|
132
|
+
* paddingHorizontal: '10%'
|
|
133
|
+
**/
|
|
134
|
+
paddingHorizontal?: number | string;
|
|
135
|
+
/**
|
|
136
|
+
* padding top and bottom (vertical) for text background
|
|
137
|
+
* @example
|
|
138
|
+
* paddingVertical: 10
|
|
139
|
+
* // or
|
|
140
|
+
* paddingVertical: '10%'
|
|
141
|
+
*/
|
|
142
|
+
paddingVertical?: number | string;
|
|
143
|
+
/**
|
|
144
|
+
* padding x, alias of paddingHorizontal
|
|
145
|
+
* @example
|
|
146
|
+
* paddingX: 10
|
|
147
|
+
* // or
|
|
148
|
+
* paddingX: '10%'
|
|
149
|
+
**/
|
|
150
|
+
paddingX?: number | string;
|
|
151
|
+
/**
|
|
152
|
+
* padding y, alias of paddingVertical
|
|
153
|
+
* @example
|
|
154
|
+
* paddingY: 10
|
|
155
|
+
* // or
|
|
156
|
+
* paddingY: '10%'
|
|
157
|
+
**/
|
|
158
|
+
paddingY?: number | string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* PositionOptions for text watermark and image watermark. When `position` is set, `X` and `Y` are treated as offsets from that anchor.
|
|
162
|
+
* @example
|
|
163
|
+
* position: {
|
|
164
|
+
* X: 10,
|
|
165
|
+
* Y: 10,
|
|
166
|
+
* }
|
|
167
|
+
* // or
|
|
168
|
+
* position: {
|
|
169
|
+
* position: Position.topLeft,
|
|
170
|
+
* }
|
|
171
|
+
* // or
|
|
172
|
+
* position: {
|
|
173
|
+
* position: Position.topRight,
|
|
174
|
+
* X: 60, // 60px from the right edge
|
|
175
|
+
* Y: 60, // 60px from the top edge
|
|
176
|
+
* }
|
|
177
|
+
* // or
|
|
178
|
+
* position: {
|
|
179
|
+
* X: '10%', // relative to the width of the background image
|
|
180
|
+
* Y: '10%', // relative to the height of the background image
|
|
181
|
+
* }
|
|
182
|
+
*/
|
|
183
|
+
export interface PositionOptions {
|
|
184
|
+
X?: number | string;
|
|
185
|
+
Y?: number | string;
|
|
186
|
+
position?: Position;
|
|
187
|
+
/**
|
|
188
|
+
* Fallback distance from the selected anchor edges when the matching `X` or
|
|
189
|
+
* `Y` value is omitted. Named anchors use the compatibility default `20`.
|
|
190
|
+
* Without a named anchor, set this value when omitted axes must behave the
|
|
191
|
+
* same on every platform; otherwise legacy text/image defaults are preserved.
|
|
192
|
+
* Percentages are resolved against the background image.
|
|
193
|
+
* @example
|
|
194
|
+
* edgeInset: 0
|
|
195
|
+
* // or
|
|
196
|
+
* edgeInset: '5%'
|
|
197
|
+
*/
|
|
198
|
+
edgeInset?: number | string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* TextStyle for text watermark
|
|
202
|
+
* @example
|
|
203
|
+
* textStyle: {
|
|
204
|
+
* color: '#aacc22',
|
|
205
|
+
* fontName: 'Arial',
|
|
206
|
+
* fontSize: 12,
|
|
207
|
+
* shadowStyle: {
|
|
208
|
+
* dx: 10,
|
|
209
|
+
* dy: 10,
|
|
210
|
+
* radius: 10,
|
|
211
|
+
* color: '#aacc22'
|
|
212
|
+
* },
|
|
213
|
+
* textBackgroundStyle: {
|
|
214
|
+
* paddingX: 10,
|
|
215
|
+
* paddingY: 10,
|
|
216
|
+
* type: TextBackgroundType.stretchX,
|
|
217
|
+
* color: '#aacc22'
|
|
218
|
+
* },
|
|
219
|
+
* underline: true,
|
|
220
|
+
* skewX: -0.25,
|
|
221
|
+
* strikeThrough: true,
|
|
222
|
+
* textAlign: 'left',
|
|
223
|
+
* italic: true,
|
|
224
|
+
* bold: true,
|
|
225
|
+
* rotate: 45
|
|
226
|
+
* }
|
|
227
|
+
*/
|
|
228
|
+
export interface TextStyle {
|
|
229
|
+
/**
|
|
230
|
+
* font color
|
|
231
|
+
* @defaultValue '#000000'
|
|
232
|
+
* @example
|
|
233
|
+
* color: '#aacc22'
|
|
234
|
+
*/
|
|
235
|
+
color?: string;
|
|
236
|
+
/**
|
|
237
|
+
* font name
|
|
238
|
+
* @example
|
|
239
|
+
* fontName: 'Arial'
|
|
240
|
+
*/
|
|
241
|
+
fontName?: string;
|
|
242
|
+
/** Ordered platform font families tried after `fontName`. */
|
|
243
|
+
fontFallbacks?: string[];
|
|
244
|
+
/**
|
|
245
|
+
* font size used when rendering text onto the output image
|
|
246
|
+
* @example
|
|
247
|
+
* fontSize: 12
|
|
248
|
+
*/
|
|
249
|
+
fontSize?: number;
|
|
250
|
+
/**
|
|
251
|
+
* font size ratio relative to the background image width
|
|
252
|
+
* @example
|
|
253
|
+
* fontSizeRatio: 0.03
|
|
254
|
+
*/
|
|
255
|
+
fontSizeRatio?: number;
|
|
256
|
+
/**
|
|
257
|
+
* Maximum text box width in output pixels or as a percentage of the
|
|
258
|
+
* background width.
|
|
259
|
+
* @example maxWidth: '60%'
|
|
260
|
+
*/
|
|
261
|
+
maxWidth?: number | string;
|
|
262
|
+
/** Absolute distance between line origins in output pixels. */
|
|
263
|
+
lineHeight?: number;
|
|
264
|
+
/** Additional spacing between grapheme clusters in output pixels. */
|
|
265
|
+
letterSpacing?: number;
|
|
266
|
+
/** Unicode base direction used for layout. @defaultValue 'auto' */
|
|
267
|
+
direction?: 'auto' | 'ltr' | 'rtl';
|
|
268
|
+
/** Wrapping strategy. @defaultValue 'word' */
|
|
269
|
+
wrap?: 'word' | 'character' | 'none';
|
|
270
|
+
/** Maximum number of rendered lines. */
|
|
271
|
+
maxLines?: number;
|
|
272
|
+
/** Behavior when text exceeds `maxWidth` or `maxLines`. @defaultValue 'clip' */
|
|
273
|
+
overflow?: 'clip' | 'ellipsis';
|
|
274
|
+
/**
|
|
275
|
+
* text shadow style
|
|
276
|
+
* @example
|
|
277
|
+
* shadowStyle: {
|
|
278
|
+
* dx: 10,
|
|
279
|
+
* dy: 10,
|
|
280
|
+
* radius: 10,
|
|
281
|
+
* color: '#aacc22'
|
|
282
|
+
* }
|
|
283
|
+
*/
|
|
284
|
+
shadowStyle?: ShadowLayerStyle | null;
|
|
285
|
+
/**
|
|
286
|
+
* text background style
|
|
287
|
+
* @example
|
|
288
|
+
* textBackgroundStyle: {
|
|
289
|
+
* paddingX: 10,
|
|
290
|
+
* paddingY: 10,
|
|
291
|
+
* type: TextBackgroundType.stretchX,
|
|
292
|
+
* color: '#aacc22'
|
|
293
|
+
* }
|
|
294
|
+
*/
|
|
295
|
+
textBackgroundStyle?: TextBackgroundStyle | null;
|
|
296
|
+
/**
|
|
297
|
+
* Optional outline drawn around the text before the fill. The width is
|
|
298
|
+
* measured in output-image pixels. Set `width` to `0` to disable it.
|
|
299
|
+
* @example
|
|
300
|
+
* strokeStyle: {
|
|
301
|
+
* color: '#00000099',
|
|
302
|
+
* width: 2,
|
|
303
|
+
* }
|
|
304
|
+
*/
|
|
305
|
+
strokeStyle?: TextStrokeStyle | null;
|
|
306
|
+
/**
|
|
307
|
+
* text underline style
|
|
308
|
+
* @defaultValue false
|
|
309
|
+
* @example
|
|
310
|
+
* underline: true
|
|
311
|
+
*/
|
|
312
|
+
underline?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Horizontal text shear factor. Use `italic` for font-provided italics.
|
|
315
|
+
* @example
|
|
316
|
+
* skewX: -0.25
|
|
317
|
+
*/
|
|
318
|
+
skewX?: number;
|
|
319
|
+
/**
|
|
320
|
+
* text strikethrough
|
|
321
|
+
* @defaultValue false
|
|
322
|
+
* @example
|
|
323
|
+
* strikeThrough: true
|
|
324
|
+
*/
|
|
325
|
+
strikeThrough?: boolean;
|
|
326
|
+
/**
|
|
327
|
+
* text align
|
|
328
|
+
* @defaultValue 'left'
|
|
329
|
+
* @example
|
|
330
|
+
* textAlign: 'left'
|
|
331
|
+
*/
|
|
332
|
+
textAlign?: 'left' | 'center' | 'right';
|
|
333
|
+
/**
|
|
334
|
+
* text italic
|
|
335
|
+
* @defaultValue false
|
|
336
|
+
* @example
|
|
337
|
+
* italic: true
|
|
338
|
+
*/
|
|
339
|
+
italic?: boolean;
|
|
340
|
+
/**
|
|
341
|
+
* text bold
|
|
342
|
+
* @defaultValue false
|
|
343
|
+
* @example
|
|
344
|
+
* bold: true
|
|
345
|
+
*/
|
|
346
|
+
bold?: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* rotate text
|
|
349
|
+
* @defaultValue 0
|
|
350
|
+
* @example
|
|
351
|
+
* rotate: 45
|
|
352
|
+
*/
|
|
353
|
+
rotate?: number;
|
|
354
|
+
}
|
|
355
|
+
/** Outline style for text watermarks. */
|
|
356
|
+
export interface TextStrokeStyle {
|
|
357
|
+
/** Outline color. */
|
|
358
|
+
color: string;
|
|
359
|
+
/** Non-negative outline width in output-image pixels. */
|
|
360
|
+
width: number;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* ShadowLayer style for text watermark
|
|
364
|
+
* @example
|
|
365
|
+
* shadowStyle: {
|
|
366
|
+
* dx: 10,
|
|
367
|
+
* dy: 10,
|
|
368
|
+
* radius: 10,
|
|
369
|
+
* color: '#aacc22'
|
|
370
|
+
* }
|
|
371
|
+
*/
|
|
372
|
+
export interface ShadowLayerStyle {
|
|
373
|
+
/**
|
|
374
|
+
* shadow offset x
|
|
375
|
+
* @example
|
|
376
|
+
* dx: 10
|
|
377
|
+
*/
|
|
378
|
+
dx: number;
|
|
379
|
+
/**
|
|
380
|
+
* shadow offset y
|
|
381
|
+
* @example
|
|
382
|
+
* dy: 10
|
|
383
|
+
**/
|
|
384
|
+
dy: number;
|
|
385
|
+
/**
|
|
386
|
+
* shadow radius
|
|
387
|
+
* @example
|
|
388
|
+
* radius: 10
|
|
389
|
+
**/
|
|
390
|
+
radius: number;
|
|
391
|
+
/**
|
|
392
|
+
* shadow color
|
|
393
|
+
* @example
|
|
394
|
+
* color: '#aacc22'
|
|
395
|
+
**/
|
|
396
|
+
color: string;
|
|
397
|
+
}
|
|
398
|
+
export interface RadiusValue {
|
|
399
|
+
x: number | string;
|
|
400
|
+
y: number | string;
|
|
401
|
+
}
|
|
402
|
+
export interface CornerRadius {
|
|
403
|
+
topLeft?: RadiusValue;
|
|
404
|
+
topRight?: RadiusValue;
|
|
405
|
+
bottomLeft?: RadiusValue;
|
|
406
|
+
bottomRight?: RadiusValue;
|
|
407
|
+
all?: RadiusValue;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* background style for text watermark
|
|
411
|
+
* > thanks [@onka13](https://github.com/onka13) for [#38](https://github.com/JimmyDaddy/react-native-image-marker/pull/38)
|
|
412
|
+
* @example
|
|
413
|
+
* textBackgroundStyle: {
|
|
414
|
+
* paddingX: 10,
|
|
415
|
+
* paddingY: 10,
|
|
416
|
+
* type: TextBackgroundType.stretchX,
|
|
417
|
+
* color: '#aacc22'
|
|
418
|
+
* }
|
|
419
|
+
* // or
|
|
420
|
+
* textBackgroundStyle: {
|
|
421
|
+
* padding: '10% 50 15%',
|
|
422
|
+
* color: '#aacc22'
|
|
423
|
+
* }
|
|
424
|
+
* // or
|
|
425
|
+
* textBackgroundStyle: {
|
|
426
|
+
* padding: 10,
|
|
427
|
+
* color: '#aacc22',
|
|
428
|
+
* cornerRadius: {
|
|
429
|
+
* topLeft: {
|
|
430
|
+
* x: '10%',
|
|
431
|
+
* y: 10,
|
|
432
|
+
* },
|
|
433
|
+
* topRight: {
|
|
434
|
+
* x: 10,
|
|
435
|
+
* y: 10,
|
|
436
|
+
* },
|
|
437
|
+
* }
|
|
438
|
+
* }
|
|
439
|
+
*/
|
|
440
|
+
export interface TextBackgroundStyle extends Padding {
|
|
441
|
+
/**
|
|
442
|
+
* background type
|
|
443
|
+
* @defaultValue TextBackgroundType.stretchX
|
|
444
|
+
* @example
|
|
445
|
+
* type: TextBackgroundType.stretchX
|
|
446
|
+
**/
|
|
447
|
+
type?: TextBackgroundType | null;
|
|
448
|
+
/**
|
|
449
|
+
* background color
|
|
450
|
+
* @example
|
|
451
|
+
* color: '#aacc22'
|
|
452
|
+
**/
|
|
453
|
+
color: string;
|
|
454
|
+
/**
|
|
455
|
+
* background corner radius
|
|
456
|
+
* @example
|
|
457
|
+
* cornerRadius: {
|
|
458
|
+
* topLeft: {
|
|
459
|
+
* x: '10%',
|
|
460
|
+
* y: 10,
|
|
461
|
+
* },
|
|
462
|
+
* topRight: {
|
|
463
|
+
* x: 10,
|
|
464
|
+
* y: 10,
|
|
465
|
+
* },
|
|
466
|
+
* bottomLeft: {
|
|
467
|
+
* x: 10,
|
|
468
|
+
* y: 10,
|
|
469
|
+
* },
|
|
470
|
+
* bottomRight: {
|
|
471
|
+
* x: '10%',
|
|
472
|
+
* y: 10,
|
|
473
|
+
* },
|
|
474
|
+
* }
|
|
475
|
+
**/
|
|
476
|
+
cornerRadius?: CornerRadius;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Text options for text watermark
|
|
480
|
+
* @example
|
|
481
|
+
* text: 'hello world',
|
|
482
|
+
* position: {
|
|
483
|
+
* X: 10,
|
|
484
|
+
* Y: 10,
|
|
485
|
+
* // or
|
|
486
|
+
* // position: Position.center
|
|
487
|
+
* },
|
|
488
|
+
* style: {
|
|
489
|
+
* color: '#aacc22',
|
|
490
|
+
* fontName: 'Arial',
|
|
491
|
+
* fontSize: 12,
|
|
492
|
+
* shadowStyle: {
|
|
493
|
+
* dx: 10,
|
|
494
|
+
* dy: 10,
|
|
495
|
+
* radius: 10,
|
|
496
|
+
* color: '#aacc22'
|
|
497
|
+
* },
|
|
498
|
+
* textBackgroundStyle: {
|
|
499
|
+
* paddingX: 10,
|
|
500
|
+
* paddingY: 10,
|
|
501
|
+
* type: TextBackgroundType.stretchX,
|
|
502
|
+
* color: '#aacc22'
|
|
503
|
+
* },
|
|
504
|
+
* underline: true,
|
|
505
|
+
* skewX: -0.25,
|
|
506
|
+
* strikeThrough: true,
|
|
507
|
+
* textAlign: 'left',
|
|
508
|
+
* italic: true,
|
|
509
|
+
* bold: true,
|
|
510
|
+
* rotate: 45
|
|
511
|
+
* }
|
|
512
|
+
*/
|
|
513
|
+
export interface TextOptions {
|
|
514
|
+
/**
|
|
515
|
+
* text content
|
|
516
|
+
* @example
|
|
517
|
+
* text: 'hello world'
|
|
518
|
+
**/
|
|
519
|
+
text: string;
|
|
520
|
+
/**
|
|
521
|
+
* Opacity applied to the complete text layer, including its fill, outline,
|
|
522
|
+
* shadow, and background.
|
|
523
|
+
* @defaultValue 1
|
|
524
|
+
* @example
|
|
525
|
+
* alpha: 0.65
|
|
526
|
+
*/
|
|
527
|
+
alpha?: number;
|
|
528
|
+
/**
|
|
529
|
+
* How this text layer is composited with the pixels already on the canvas.
|
|
530
|
+
* @defaultValue 'normal'
|
|
531
|
+
*/
|
|
532
|
+
blendMode?: BlendMode;
|
|
533
|
+
/**
|
|
534
|
+
* text position options
|
|
535
|
+
* @example
|
|
536
|
+
* position: {
|
|
537
|
+
* X: 10,
|
|
538
|
+
* Y: 10,
|
|
539
|
+
* // or
|
|
540
|
+
* // position: Position.center
|
|
541
|
+
* }
|
|
542
|
+
*/
|
|
543
|
+
position?: PositionOptions;
|
|
544
|
+
/**
|
|
545
|
+
* Render this watermark once or repeat it across the image. Tiled layouts
|
|
546
|
+
* cannot be combined with `position`.
|
|
547
|
+
* @defaultValue `{ type: 'single' }`
|
|
548
|
+
*/
|
|
549
|
+
layout?: WatermarkLayout;
|
|
550
|
+
/**
|
|
551
|
+
* text style
|
|
552
|
+
* @example
|
|
553
|
+
* style: {
|
|
554
|
+
* color: '#aacc22',
|
|
555
|
+
* fontName: 'Arial',
|
|
556
|
+
* fontSize: 12,
|
|
557
|
+
* shadowStyle: {
|
|
558
|
+
* dx: 10,
|
|
559
|
+
* dy: 10,
|
|
560
|
+
* radius: 10,
|
|
561
|
+
* color: '#aacc22'
|
|
562
|
+
* },
|
|
563
|
+
* textBackgroundStyle: {
|
|
564
|
+
* paddingX: 10,
|
|
565
|
+
* paddingY: 10,
|
|
566
|
+
* type: TextBackgroundType.stretchX,
|
|
567
|
+
* color: '#aacc22'
|
|
568
|
+
* },
|
|
569
|
+
* underline: true,
|
|
570
|
+
* strikeThrough: true,
|
|
571
|
+
* textAlign: 'left',
|
|
572
|
+
* italic: true,
|
|
573
|
+
* // or
|
|
574
|
+
* // skewX: -0.25,
|
|
575
|
+
* bold: true,
|
|
576
|
+
* rotate: 45
|
|
577
|
+
* }
|
|
578
|
+
*/
|
|
579
|
+
style?: TextStyle;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Options for text watermark
|
|
583
|
+
* @example
|
|
584
|
+
* backgroundImage: {
|
|
585
|
+
* src: require('./images/logo.png'),
|
|
586
|
+
* scale: 0.5,
|
|
587
|
+
* rotate: 45,
|
|
588
|
+
* alpha: 0.5
|
|
589
|
+
* },
|
|
590
|
+
* watermarkTexts: [
|
|
591
|
+
* {
|
|
592
|
+
* text: 'hello world',
|
|
593
|
+
* position: {
|
|
594
|
+
* X: 10,
|
|
595
|
+
* Y: 10,
|
|
596
|
+
* // or
|
|
597
|
+
* // position: Position.center
|
|
598
|
+
* },
|
|
599
|
+
* style: {
|
|
600
|
+
* color: '#aacc22',
|
|
601
|
+
* fontName: 'Arial',
|
|
602
|
+
* fontSize: 12,
|
|
603
|
+
* shadowStyle: {
|
|
604
|
+
* dx: 10,
|
|
605
|
+
* dy: 10,
|
|
606
|
+
* radius: 10,
|
|
607
|
+
* color: '#aacc22'
|
|
608
|
+
* },
|
|
609
|
+
* textBackgroundStyle: {
|
|
610
|
+
* paddingX: 10,
|
|
611
|
+
* paddingY: 10,
|
|
612
|
+
* type: TextBackgroundType.stretchX,
|
|
613
|
+
* color: '#aacc22'
|
|
614
|
+
* },
|
|
615
|
+
* underline: true,
|
|
616
|
+
* strikeThrough: true,
|
|
617
|
+
* textAlign: 'left',
|
|
618
|
+
* italic: true,
|
|
619
|
+
* //or
|
|
620
|
+
* // skewX: -0.25,
|
|
621
|
+
* bold: true,
|
|
622
|
+
* rotate: 45
|
|
623
|
+
* }
|
|
624
|
+
* }],
|
|
625
|
+
* quality: 100,
|
|
626
|
+
* filename: 'test',
|
|
627
|
+
* saveFormat: ImageFormat.jpg,
|
|
628
|
+
*/
|
|
629
|
+
export interface TextMarkOptions {
|
|
630
|
+
/**
|
|
631
|
+
* background image options
|
|
632
|
+
* @example
|
|
633
|
+
* backgroundImage: {
|
|
634
|
+
* src: require('./images/logo.png'),
|
|
635
|
+
* scale: 0.5,
|
|
636
|
+
* rotate: 45,
|
|
637
|
+
* alpha: 0.5
|
|
638
|
+
* }
|
|
639
|
+
**/
|
|
640
|
+
backgroundImage: ImageOptions;
|
|
641
|
+
/**
|
|
642
|
+
* text options
|
|
643
|
+
* @example
|
|
644
|
+
* watermarkTexts: [
|
|
645
|
+
* {
|
|
646
|
+
* text: 'hello world',
|
|
647
|
+
* position: {
|
|
648
|
+
* X: 10,
|
|
649
|
+
* Y: 10,
|
|
650
|
+
* // or
|
|
651
|
+
* // position: Position.center
|
|
652
|
+
* },
|
|
653
|
+
* style: {
|
|
654
|
+
* color: '#aacc22',
|
|
655
|
+
* fontName: 'Arial',
|
|
656
|
+
* fontSize: 12,
|
|
657
|
+
* shadowStyle: {
|
|
658
|
+
* dx: 10,
|
|
659
|
+
* dy: 10,
|
|
660
|
+
* radius: 10,
|
|
661
|
+
* color: '#aacc22'
|
|
662
|
+
* },
|
|
663
|
+
* textBackgroundStyle: {
|
|
664
|
+
* paddingX: 10,
|
|
665
|
+
* paddingY: 10,
|
|
666
|
+
* type: TextBackgroundType.stretchX,
|
|
667
|
+
* color: '#aacc22'
|
|
668
|
+
* },
|
|
669
|
+
* underline: true,
|
|
670
|
+
* strikeThrough: true,
|
|
671
|
+
* textAlign: 'left',
|
|
672
|
+
* italic: true,
|
|
673
|
+
* //or
|
|
674
|
+
* // skewX: -0.25,
|
|
675
|
+
* bold: true,
|
|
676
|
+
* rotate: 45
|
|
677
|
+
* }
|
|
678
|
+
* }]
|
|
679
|
+
**/
|
|
680
|
+
watermarkTexts: TextOptions[];
|
|
681
|
+
/**
|
|
682
|
+
* Integer image quality from `0` to `100`, where `100` is best. Quality has
|
|
683
|
+
* the most visible effect when the output format is `jpg`. See #159.
|
|
684
|
+
* @defaultValue 100
|
|
685
|
+
* @example
|
|
686
|
+
* quality: 100
|
|
687
|
+
*/
|
|
688
|
+
quality?: number;
|
|
689
|
+
/**
|
|
690
|
+
* save image name
|
|
691
|
+
* @example
|
|
692
|
+
* filename: 'test'
|
|
693
|
+
**/
|
|
694
|
+
filename?: string;
|
|
695
|
+
/**
|
|
696
|
+
* save image format
|
|
697
|
+
* @defaultValue `jpg`
|
|
698
|
+
* @example
|
|
699
|
+
* saveFormat: ImageFormat.png
|
|
700
|
+
*/
|
|
701
|
+
saveFormat?: ImageFormat;
|
|
702
|
+
/**
|
|
703
|
+
* Matte color used when an output with transparency is encoded as JPEG.
|
|
704
|
+
* JPEG has no alpha channel, so transparent pixels are composited over this
|
|
705
|
+
* color before encoding.
|
|
706
|
+
* @defaultValue `#FFFFFF`
|
|
707
|
+
* @example
|
|
708
|
+
* matteColor: '#FFFFFF'
|
|
709
|
+
*/
|
|
710
|
+
matteColor?: string;
|
|
711
|
+
/**
|
|
712
|
+
* Controls whether background rotation expands the output canvas or crops
|
|
713
|
+
* back to the original canvas dimensions.
|
|
714
|
+
* @defaultValue RotationCanvasMode.expand
|
|
715
|
+
* @example
|
|
716
|
+
* rotationCanvasMode: RotationCanvasMode.crop
|
|
717
|
+
*/
|
|
718
|
+
rotationCanvasMode?: RotationCanvasMode;
|
|
719
|
+
/**
|
|
720
|
+
* Maximum width or height used while decoding or rendering source images.
|
|
721
|
+
* Larger images keep their aspect ratio on iOS, Android, and Web.
|
|
722
|
+
* @defaultValue 2048
|
|
723
|
+
* @example
|
|
724
|
+
* maxSize: 2048
|
|
725
|
+
*/
|
|
726
|
+
maxSize?: number;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Image options for background image or watermark image
|
|
730
|
+
* @example
|
|
731
|
+
* {
|
|
732
|
+
* src: require('./images/logo.png'),
|
|
733
|
+
* scale: 0.5,
|
|
734
|
+
* rotate: 45,
|
|
735
|
+
* alpha: 0.5
|
|
736
|
+
* }
|
|
737
|
+
*/
|
|
738
|
+
export interface ImageOptions {
|
|
739
|
+
/**
|
|
740
|
+
* Image source. Supports React Native image sources and base64 data URLs.
|
|
741
|
+
* @example
|
|
742
|
+
* src: require('./images/logo.png')
|
|
743
|
+
*/
|
|
744
|
+
src: any;
|
|
745
|
+
/**
|
|
746
|
+
* image scale `>0`
|
|
747
|
+
* @defaultValue 1
|
|
748
|
+
* @example
|
|
749
|
+
* scale: 1
|
|
750
|
+
*/
|
|
751
|
+
scale?: number;
|
|
752
|
+
/**
|
|
753
|
+
* rotate image rotate `0-360`
|
|
754
|
+
* @defaultValue 0
|
|
755
|
+
* @example
|
|
756
|
+
* rotate: 45
|
|
757
|
+
*/
|
|
758
|
+
rotate?: number;
|
|
759
|
+
/**
|
|
760
|
+
* Image opacity from `0` (transparent) to `1` (opaque).
|
|
761
|
+
* @defaultValue 1
|
|
762
|
+
* @example
|
|
763
|
+
* alpha: 0.5
|
|
764
|
+
*/
|
|
765
|
+
alpha?: number;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Options for one image watermark layer.
|
|
769
|
+
* @example
|
|
770
|
+
* src: require('./images/logo.png'),
|
|
771
|
+
* scale: 0.5,
|
|
772
|
+
* rotate: 45,
|
|
773
|
+
* alpha: 0.5
|
|
774
|
+
* position: {
|
|
775
|
+
* X: 10,
|
|
776
|
+
* Y: 10,
|
|
777
|
+
* // or
|
|
778
|
+
* // position: Position.center
|
|
779
|
+
* }
|
|
780
|
+
**/
|
|
781
|
+
export interface WatermarkImageOptions extends ImageOptions {
|
|
782
|
+
/**
|
|
783
|
+
* How this watermark image is composited with the pixels already on the canvas.
|
|
784
|
+
* Background images intentionally do not expose this option.
|
|
785
|
+
* @defaultValue 'normal'
|
|
786
|
+
*/
|
|
787
|
+
blendMode?: BlendMode;
|
|
788
|
+
position?: PositionOptions;
|
|
789
|
+
/**
|
|
790
|
+
* Render this watermark once or repeat it across the image. Tiled layouts
|
|
791
|
+
* cannot be combined with `position`.
|
|
792
|
+
* @defaultValue `{ type: 'single' }`
|
|
793
|
+
*/
|
|
794
|
+
layout?: WatermarkLayout;
|
|
795
|
+
/**
|
|
796
|
+
* Remove fully transparent outer rows and columns before scaling, rotating,
|
|
797
|
+
* and positioning the watermark.
|
|
798
|
+
* @defaultValue false
|
|
799
|
+
*/
|
|
800
|
+
trimTransparentPadding?: boolean;
|
|
801
|
+
}
|
|
802
|
+
/** Controls whether a watermark layer is drawn once or tiled over the image. */
|
|
803
|
+
export type WatermarkLayout = {
|
|
804
|
+
type?: 'single';
|
|
805
|
+
} | {
|
|
806
|
+
type: 'tile';
|
|
807
|
+
/** Horizontal space between rotated watermark bounds. */
|
|
808
|
+
gapX?: number | string;
|
|
809
|
+
/** Vertical space between rotated watermark bounds. */
|
|
810
|
+
gapY?: number | string;
|
|
811
|
+
/** Horizontal grid offset in pixels or as a percentage of canvas width. */
|
|
812
|
+
offsetX?: number | string;
|
|
813
|
+
/** Vertical grid offset in pixels or as a percentage of canvas height. */
|
|
814
|
+
offsetY?: number | string;
|
|
815
|
+
/** Shift every other row by half of its horizontal step. */
|
|
816
|
+
stagger?: boolean;
|
|
817
|
+
};
|
|
818
|
+
/**
|
|
819
|
+
* Options for rendering image-only watermark layers.
|
|
820
|
+
* @example
|
|
821
|
+
*
|
|
822
|
+
* backgroundImage: {
|
|
823
|
+
* src: require('./images/bg.png'),
|
|
824
|
+
* scale: 0.5,
|
|
825
|
+
* rotate: 45,
|
|
826
|
+
* alpha: 0.5
|
|
827
|
+
* },
|
|
828
|
+
* watermarkImages: [
|
|
829
|
+
* {
|
|
830
|
+
* src: require('./images/logo.png'),
|
|
831
|
+
* scale: 0.5,
|
|
832
|
+
* rotate: 45,
|
|
833
|
+
* alpha: 0.5,
|
|
834
|
+
* position: {
|
|
835
|
+
* X: 10,
|
|
836
|
+
* Y: 10,
|
|
837
|
+
* },
|
|
838
|
+
* },
|
|
839
|
+
* {
|
|
840
|
+
* src: require('./images/logo1.png'),
|
|
841
|
+
* scale: 0.5,
|
|
842
|
+
* rotate: 45,
|
|
843
|
+
* alpha: 0.5,
|
|
844
|
+
* position: {
|
|
845
|
+
* position: Position.center,
|
|
846
|
+
* },
|
|
847
|
+
* },
|
|
848
|
+
* ],
|
|
849
|
+
* quality: 100,
|
|
850
|
+
* filename: 'test',
|
|
851
|
+
* saveFormat: ImageFormat.jpg,
|
|
852
|
+
*
|
|
853
|
+
*/
|
|
854
|
+
export interface ImageMarkOptions {
|
|
855
|
+
/**
|
|
856
|
+
* background image options
|
|
857
|
+
* @example
|
|
858
|
+
* backgroundImage: {
|
|
859
|
+
* src: require('./images/bg.png'),
|
|
860
|
+
* scale: 0.5,
|
|
861
|
+
* rotate: 45,
|
|
862
|
+
* alpha: 0.5
|
|
863
|
+
* }
|
|
864
|
+
**/
|
|
865
|
+
backgroundImage: ImageOptions;
|
|
866
|
+
/**
|
|
867
|
+
* Integer image quality from `0` to `100`, where `100` is best.
|
|
868
|
+
* @defaultValue 100
|
|
869
|
+
* @example
|
|
870
|
+
* quality: 100
|
|
871
|
+
*/
|
|
872
|
+
quality?: number;
|
|
873
|
+
/**
|
|
874
|
+
* save image name
|
|
875
|
+
* @example
|
|
876
|
+
* filename: 'test'
|
|
877
|
+
**/
|
|
878
|
+
filename?: string;
|
|
879
|
+
/**
|
|
880
|
+
* save image format
|
|
881
|
+
* @defaultValue `jpg`
|
|
882
|
+
* @example
|
|
883
|
+
* saveFormat: ImageFormat.jpg
|
|
884
|
+
*/
|
|
885
|
+
saveFormat?: ImageFormat;
|
|
886
|
+
/**
|
|
887
|
+
* Matte color used when an output with transparency is encoded as JPEG.
|
|
888
|
+
* @defaultValue `#FFFFFF`
|
|
889
|
+
*/
|
|
890
|
+
matteColor?: string;
|
|
891
|
+
/**
|
|
892
|
+
* Controls whether background rotation expands the output canvas or crops
|
|
893
|
+
* back to the original canvas dimensions.
|
|
894
|
+
* @defaultValue RotationCanvasMode.expand
|
|
895
|
+
*/
|
|
896
|
+
rotationCanvasMode?: RotationCanvasMode;
|
|
897
|
+
/**
|
|
898
|
+
* Maximum width or height used while decoding or rendering source images.
|
|
899
|
+
* Larger images keep their aspect ratio on iOS, Android, and Web.
|
|
900
|
+
* @defaultValue 2048
|
|
901
|
+
* @example
|
|
902
|
+
* maxSize: 2048
|
|
903
|
+
*/
|
|
904
|
+
maxSize?: number;
|
|
905
|
+
/**
|
|
906
|
+
* watermark images
|
|
907
|
+
* @example
|
|
908
|
+
* watermarkImages: [
|
|
909
|
+
* {
|
|
910
|
+
* src: require('./images/logo.png'),
|
|
911
|
+
* scale: 0.5,
|
|
912
|
+
* rotate: 45,
|
|
913
|
+
* alpha: 0.5,
|
|
914
|
+
* position: {
|
|
915
|
+
* X: 10,
|
|
916
|
+
* Y: 10,
|
|
917
|
+
* // or
|
|
918
|
+
* position: Position.center
|
|
919
|
+
* }
|
|
920
|
+
* }]
|
|
921
|
+
**/
|
|
922
|
+
watermarkImages?: Array<WatermarkImageOptions>;
|
|
923
|
+
}
|
|
924
|
+
export interface TextWatermarkLayer extends TextOptions {
|
|
925
|
+
type: 'text';
|
|
926
|
+
}
|
|
927
|
+
export interface ImageWatermarkLayer extends WatermarkImageOptions {
|
|
928
|
+
type: 'image';
|
|
929
|
+
}
|
|
930
|
+
export type WatermarkLayer = TextWatermarkLayer | ImageWatermarkLayer;
|
|
931
|
+
/**
|
|
932
|
+
* Options for marking text and image watermarks with a single call.
|
|
933
|
+
* @example
|
|
934
|
+
* await Marker.mark({
|
|
935
|
+
* backgroundImage: {
|
|
936
|
+
* src: require('./images/bg.png'),
|
|
937
|
+
* },
|
|
938
|
+
* watermarks: [
|
|
939
|
+
* {
|
|
940
|
+
* type: 'text',
|
|
941
|
+
* text: 'hello world',
|
|
942
|
+
* position: {
|
|
943
|
+
* position: Position.bottomCenter,
|
|
944
|
+
* Y: 24,
|
|
945
|
+
* },
|
|
946
|
+
* style: {
|
|
947
|
+
* color: '#FFFFFF',
|
|
948
|
+
* fontSize: 32,
|
|
949
|
+
* },
|
|
950
|
+
* },
|
|
951
|
+
* {
|
|
952
|
+
* type: 'image',
|
|
953
|
+
* src: require('./images/logo.png'),
|
|
954
|
+
* position: {
|
|
955
|
+
* position: Position.topRight,
|
|
956
|
+
* X: 24,
|
|
957
|
+
* Y: 24,
|
|
958
|
+
* },
|
|
959
|
+
* scale: 0.5,
|
|
960
|
+
* },
|
|
961
|
+
* ],
|
|
962
|
+
* saveFormat: ImageFormat.png,
|
|
963
|
+
* });
|
|
964
|
+
*/
|
|
965
|
+
export interface MarkOptions {
|
|
966
|
+
/**
|
|
967
|
+
* Background image options.
|
|
968
|
+
*/
|
|
969
|
+
backgroundImage: ImageOptions;
|
|
970
|
+
/**
|
|
971
|
+
* Ordered watermark layers. Layers are rendered in array order, so later layers draw over earlier layers.
|
|
972
|
+
*/
|
|
973
|
+
watermarks?: WatermarkLayer[];
|
|
974
|
+
/**
|
|
975
|
+
* Text watermark options. Kept for compatibility; use watermarks instead for ordered mixed layers.
|
|
976
|
+
*/
|
|
977
|
+
watermarkTexts?: TextOptions[];
|
|
978
|
+
/**
|
|
979
|
+
* Image watermark options. Kept for compatibility; use watermarks instead for ordered mixed layers.
|
|
980
|
+
*/
|
|
981
|
+
watermarkImages?: Array<WatermarkImageOptions>;
|
|
982
|
+
/**
|
|
983
|
+
* Integer image quality from `0` to `100`, where `100` is best.
|
|
984
|
+
* @defaultValue 100
|
|
985
|
+
*/
|
|
986
|
+
quality?: number;
|
|
987
|
+
/**
|
|
988
|
+
* save image name
|
|
989
|
+
*/
|
|
990
|
+
filename?: string;
|
|
991
|
+
/**
|
|
992
|
+
* save image format
|
|
993
|
+
* @defaultValue `jpg`
|
|
994
|
+
*/
|
|
995
|
+
saveFormat?: ImageFormat;
|
|
996
|
+
/**
|
|
997
|
+
* Matte color used when an output with transparency is encoded as JPEG.
|
|
998
|
+
* @defaultValue `#FFFFFF`
|
|
999
|
+
*/
|
|
1000
|
+
matteColor?: string;
|
|
1001
|
+
/**
|
|
1002
|
+
* Controls whether background rotation expands the output canvas or crops
|
|
1003
|
+
* back to the original canvas dimensions.
|
|
1004
|
+
* @defaultValue RotationCanvasMode.expand
|
|
1005
|
+
*/
|
|
1006
|
+
rotationCanvasMode?: RotationCanvasMode;
|
|
1007
|
+
/**
|
|
1008
|
+
* Maximum width or height used while decoding or rendering source images.
|
|
1009
|
+
* Larger images keep their aspect ratio on iOS, Android, and Web.
|
|
1010
|
+
* @defaultValue 2048
|
|
1011
|
+
*/
|
|
1012
|
+
maxSize?: number;
|
|
1013
|
+
}
|
|
1014
|
+
export default Marker;
|