@qrcommunication/gigapdf-lib 0.68.0 → 0.69.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 CHANGED
@@ -4,6 +4,24 @@ All notable changes to `@qrcommunication/gigapdf-lib` are documented here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/) and the
5
5
  project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.69.0] - 2026-06-23
8
+
9
+ Image-watermark release: stamp a raster image across any range of pages, with
10
+ the same ergonomics as the existing text watermark. The text watermark is
11
+ unchanged.
12
+
13
+ ### Added
14
+
15
+ - **Image watermark.** Stamp a raster image over pages —
16
+ `addImageWatermark` (SDK) / `add_image_watermark` (core) /
17
+ `gp_add_image_watermark` (FFI). Accepts **PNG / JPEG / WebP / GIF / AVIF**
18
+ source images and supports per-watermark **opacity**, **anchoring**
19
+ (center + four corners) with offsets, **rotation** (about the image center),
20
+ **scaling** to a target size (aspect-follow), and an optional **tiling** grid.
21
+ The image XObject is embedded **once** and referenced on each target page,
22
+ reusing the existing image-embed/raster-transcode pipeline. The text
23
+ watermark and `add_image` behavior are unchanged.
24
+
7
25
  ## [0.68.0] - 2026-06-23
8
26
 
9
27
  Format-reach + import/render fidelity release: the unified model now exports
package/dist/index.cjs CHANGED
@@ -1239,6 +1239,49 @@ var GigaPdfDoc = class {
1239
1239
  (p, l) => this.ex().gp_add_image(this.h, page, p, l, x, y, w, h, opacity)
1240
1240
  ) === 0;
1241
1241
  }
1242
+ /**
1243
+ * Stamp an **image watermark** across pages from raw image bytes. Accepts the
1244
+ * same five formats the engine decodes — **PNG, JPEG, WebP, GIF, AVIF**. The
1245
+ * image is embedded **once** and referenced on every target page.
1246
+ *
1247
+ * `opts.pages` is a list of 1-based page numbers; omit it (or pass `[]`) to
1248
+ * stamp every page. `opts.anchor` positions the image (`'center'` default, or a
1249
+ * corner) and `opts.offsetX`/`offsetY` nudge it (in points; in `tile` mode they
1250
+ * become the gaps between tiles). `opts.width`/`height` set the target size in
1251
+ * points (height keeps the source aspect ratio when omitted). `opts.rotationDeg`
1252
+ * rotates about the image centre and `opts.opacity` (0–1) sets the alpha.
1253
+ * Returns `false` if the image can't be decoded.
1254
+ */
1255
+ addImageWatermark(data, opts = {}) {
1256
+ const anchorTag = {
1257
+ center: 0,
1258
+ "top-left": 1,
1259
+ "top-right": 2,
1260
+ "bottom-left": 3,
1261
+ "bottom-right": 4
1262
+ }[opts.anchor ?? "center"];
1263
+ const pages = opts.pages ?? [];
1264
+ const call = (pp, pc) => this.g._withBytes(
1265
+ data,
1266
+ (p, l) => this.ex().gp_add_image_watermark(
1267
+ this.h,
1268
+ p,
1269
+ l,
1270
+ pp,
1271
+ pc,
1272
+ anchorTag,
1273
+ opts.offsetX ?? 0,
1274
+ opts.offsetY ?? 0,
1275
+ opts.width ?? 0,
1276
+ opts.height ?? 0,
1277
+ opts.rotationDeg ?? 0,
1278
+ opts.opacity ?? 0.25,
1279
+ opts.tile ? 1 : 0
1280
+ )
1281
+ );
1282
+ const rc = pages.length === 0 ? call(0, 0) : this.g._withU32(pages, (pp, pc) => call(pp, pc));
1283
+ return rc === 0;
1284
+ }
1242
1285
  /**
1243
1286
  * Draw SVG markup on a page as **native vector paths** (crisp at any zoom, not
1244
1287
  * rasterized), fitting its `viewBox` into the box `(x, y, w, h)` in PDF points