Expose PNG metadata comments (#4157)

This commit is contained in:
Nathan Keynes
2024-07-19 03:08:03 +10:00
committed by GitHub
parent c2a024101b
commit d642108be2
6 changed files with 70 additions and 0 deletions

7
lib/index.d.ts vendored
View File

@@ -1108,6 +1108,8 @@ declare namespace sharp {
resolutionUnit?: 'inch' | 'cm' | undefined;
/** String containing format for images loaded via *magick */
formatMagick?: string | undefined;
/** Array of keyword/text pairs representing PNG text blocks, if present. */
comments?: CommentsMetadata[] | undefined;
}
interface LevelMetadata {
@@ -1115,6 +1117,11 @@ declare namespace sharp {
height: number;
}
interface CommentsMetadata {
keyword: string;
text: string;
}
interface Stats {
/** Array of channel statistics for each channel in the image. */
channels: ChannelStats[];

View File

@@ -450,6 +450,7 @@ function _isStreamInput () {
* - `xmp`: Buffer containing raw XMP data, if present
* - `tifftagPhotoshop`: Buffer containing raw TIFFTAG_PHOTOSHOP data, if present
* - `formatMagick`: String containing format for images loaded via *magick
* - `comments` Array of keyword/text pairs representing PNG text blocks, if present.
*
* @example
* const metadata = await sharp(input).metadata();