From edf1f7ace787efce0893128d543538c11cb0d461 Mon Sep 17 00:00:00 2001 From: Abhishek V Date: Sat, 23 Dec 2023 17:27:41 +0530 Subject: [PATCH 1/2] Added typescript prompt for keepmetadata --- lib/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/index.d.ts b/lib/index.d.ts index 5ed415775..c68c848db 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -341,6 +341,12 @@ declare namespace sharp { */ metadata(): Promise; + /** + * Keep all metadata (EXIF, ICC, XMP, IPTC) from the input image in the output image. + * @returns A sharp instance that can be used to chain operations + */ + keepMetadata(): Sharp; + /** * Access to pixel-derived image statistics for every channel in the image. * @returns A sharp instance that can be used to chain operations From a680b7df2cd8980d3dbdfe6d55e7576c003e83d2 Mon Sep 17 00:00:00 2001 From: Abhishek V Date: Sun, 24 Dec 2023 15:31:06 +0530 Subject: [PATCH 2/2] add a test case to sharp.test-d.ts for keepMetadata --- test/types/sharp.test-d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/types/sharp.test-d.ts b/test/types/sharp.test-d.ts index 4be5eeb60..1c08ae35a 100644 --- a/test/types/sharp.test-d.ts +++ b/test/types/sharp.test-d.ts @@ -44,6 +44,12 @@ sharp('input.png') // sharpened, with metadata, 90% quality WebP image data. Phew! }); +sharp('input.png') + .keepMetadata() + .toFile('output.png', (err, info) => { + // output.png is an image containing input.png along with all metadata(EXIF, ICC, XMP, IPTC) from input.png + }) + sharp('input.jpg') .resize(300, 200) .toFile('output.jpg', (err: Error) => {