Skip to content

Commit

Permalink
TypeScript: add definition for keepMetadata (#3914)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi0498 committed Dec 24, 2023
1 parent cd5cf7c commit 77ab5d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/index.d.ts
Expand Up @@ -341,6 +341,12 @@ declare namespace sharp {
*/
metadata(): Promise<Metadata>;

/**
* 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
Expand Down
6 changes: 6 additions & 0 deletions test/types/sharp.test-d.ts
Expand Up @@ -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) => {
Expand Down

0 comments on commit 77ab5d7

Please sign in to comment.