TypeScript: add definition for keepMetadata (#3914)

This commit is contained in:
Abhishek V 2023-12-24 15:54:54 +05:30 committed by GitHub
parent cd5cf7ce2d
commit 77ab5d7a51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

6
lib/index.d.ts vendored
View File

@ -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

View File

@ -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) => {