Skip to content

Commit 0da314a

Browse files
authored
fix: remove unnecessary static method (#8)
This pull request includes changes to the `IDWatermark` class in `src/index.js` to improve the image loading process and simplify the codebase. The most important changes include replacing the `loadImage` method with a direct call to `createImageBitmap` and removing the now redundant `loadImage` method. Improvements to image loading process: * [`src/index.js`](diffhunk://#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556L80-R80): Replaced the call to `IDWatermark.loadImage` with a direct call to `createImageBitmap` in the `addWatermark` method. Codebase simplification: * [`src/index.js`](diffhunk://#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556L212-L222): Removed the `loadImage` static method from the `IDWatermark` class as it is no longer needed.
2 parents 11b6e3f + 8942bdd commit 0da314a

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

src/index.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class IDWatermark {
7777
*/
7878
async addWatermark(imageInput, watermarkText, encodeOptions = {}) {
7979

80-
const image = await IDWatermark.loadImage(imageInput, this.bitmapOptions);
80+
const image = await createImageBitmap(imageInput, this.bitmapOptions);
8181

8282
const canvas = new OffscreenCanvas(image.width, image.height);
8383
const ctx = canvas.getContext('2d', { willReadFrequently: true });
@@ -209,17 +209,6 @@ class IDWatermark {
209209
ctx.putImageData(imageData, 0, 0);
210210
}
211211

212-
/**
213-
* Loads an image from a source.
214-
*
215-
* @param {File|Blob|ImageData|ImageBitmap|OffscreenCanvas|VideoFrame|HTMLImageElement|SVGImageElement|HTMLCanvasElement} input - The input image.
216-
* @param {Object} options - ImageBitmap options.
217-
* @returns {Promise<ImageBitmap>} - A promise that resolves to an ImageBitmap.
218-
*/
219-
static async loadImage(input, options = {}) {
220-
return createImageBitmap(input, options);
221-
}
222-
223212
/**
224213
* Returns the default options for the watermark.
225214
*

0 commit comments

Comments
 (0)