From 18f507f00a981020b0bcbba72d4a71a412364a27 Mon Sep 17 00:00:00 2001 From: Mattias Wallander Date: Sat, 21 Oct 2023 16:52:06 +0200 Subject: [PATCH] Add types for extended WebP tags --- exif-reader.d.ts | 24 ++++++++++++++++++++++-- test/types/exif-reader.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/exif-reader.d.ts b/exif-reader.d.ts index fe59222..723b175 100644 --- a/exif-reader.d.ts +++ b/exif-reader.d.ts @@ -81,6 +81,25 @@ interface PngTextTags { [name: string]: PngTextTag } +interface RiffTags { + 'Alpha'?: { + value: 0 | 1, + description: 'No' | 'Yes' + }, + 'Animation'?: { + value: 0 | 1, + description: 'No' | 'Yes' + }, + 'ImageWidth'?: { + value: number, + description: string + }, + 'ImageHeight'?: { + value: number, + description: string + } +} + interface NumberFileTag { description: string, value: number @@ -153,6 +172,7 @@ interface ExpandedTags { iptc?: ExifTags, xmp?: { _raw: string } & XmpTags, icc?: IccTags, + riff?: RiffTags, Thumbnail?: ThumbnailTags, gps?: GpsTags } @@ -453,9 +473,9 @@ interface IccTags { [name: string]: ValueTag; } -export type Tags = XmpTags & IccTags & PngTags & { +export type Tags = XmpTags & IccTags & PngTags & RiffTags & { 'Thumbnail'?: ThumbnailTags; 'Images'?: MPFImageTags[], } & { [K in keyof ExifTags]: ExifTags[K] | XmpTag; -} \ No newline at end of file +} diff --git a/test/types/exif-reader.ts b/test/types/exif-reader.ts index a5dee02..b1fa355 100644 --- a/test/types/exif-reader.ts +++ b/test/types/exif-reader.ts @@ -84,3 +84,37 @@ expandedTags.png?.["Pixel Units"]?.description === "meters"; // @ts-expect-error expandedTags.png?.["Color Type"]?.description === "A non-color type value"; expandedTags.png?.["Custom Tag Name"]?.description === "Should work"; + +///////// +// RIFF +tags["Alpha"]?.value === 0; +tags["Alpha"]?.description === 'Yes'; +tags["Alpha"]?.description === 'No'; +// @ts-expect-error +tags["Alpha"]?.description === 'Maybe'; +expandedTags["riff"]?.["Alpha"]?.value === 0; +expandedTags["riff"]?.["Alpha"]?.description === 'Yes'; +expandedTags["riff"]?.["Alpha"]?.description === 'No'; +// @ts-expect-error +expandedTags["riff"]?.["Alpha"]?.description === 'Maybe'; + +tags["Animation"]?.value === 0; +tags["Animation"]?.description === 'Yes'; +tags["Animation"]?.description === 'No'; +// @ts-expect-error +tags["Animation"]?.description === 'Maybe'; +expandedTags["riff"]?.["Animation"]?.value === 0; +expandedTags["riff"]?.["Animation"]?.description === 'Yes'; +expandedTags["riff"]?.["Animation"]?.description === 'No'; +// @ts-expect-error +expandedTags["riff"]?.["Animation"]?.description === 'Maybe'; + +tags["ImageWidth"]?.value === 100; +tags["ImageWidth"]?.description === '100px'; +expandedTags["riff"]?.["ImageWidth"]?.value === 100; +expandedTags["riff"]?.["ImageWidth"]?.description === '100px'; + +tags["ImageHeight"]?.value === 100; +tags["ImageHeight"]?.description === '100px'; +expandedTags["riff"]?.["ImageHeight"]?.value === 100; +expandedTags["riff"]?.["ImageHeight"]?.description === '100px';