UNPKG

astro-image-exif-loader

Version:

Astro content collection loader for extracting EXIF data from images

49 lines (46 loc) 3.13 kB
import { ExifLoaderOptions, ExifToolTagKeys, ExifPresets, NarrowedExifData, MaybeUndefinedSelected, ExifCollectionDefinition, ExtractAllExifData, ExtractAllExifDataNoRaw, NarrowedExifDataNoRaw } from './types.js'; import { Loader } from 'astro/loaders'; import { z } from 'astro/zod'; import 'astro'; import 'exiftool-vendored'; declare function createExifLoader(options?: ExifLoaderOptions): Loader; declare function exifSchema<const TSel extends readonly ExifToolTagKeys[] | undefined = undefined, const PSel extends readonly ExifPresets[] | undefined = undefined>(zod: typeof z, _options?: Pick<ExifLoaderOptions, "includeRawExif">): z.ZodObject<any, any, any, NarrowedExifData<MaybeUndefinedSelected<TSel, PSel>>>; /** * Convenience helper to define an EXIF collection with loader and matching schema. * Provides type-safe EXIF data extraction with automatic TypeScript narrowing. * * Options: * - imagesDir: Configure directory scanning with pattern and base path * - presets: Use predefined EXIF tag groups like "camera", "exposure", "location" * - tags: Specify individual EXIF tags to extract * - extractAll: Extract all available EXIF data with full TypeScript support * - includeRawExif: Include complete unfiltered EXIF data in rawExif property * - excludeTags: Filter out specific tags like GPS coordinates for privacy * * Returns a collection definition with loader and schema for use in Astro content config. */ declare function defineExifCollection<const ESel extends readonly ExifToolTagKeys[] | undefined = undefined>(options: ExifLoaderOptions & { extractAll: true; includeRawExif: true; excludeTags?: ESel; }): ExifCollectionDefinition<z.ZodObject<any, any, any, ExtractAllExifData<ESel>>>; declare function defineExifCollection<const ESel extends readonly ExifToolTagKeys[] | undefined = undefined>(options: ExifLoaderOptions & { extractAll: true; includeRawExif?: false; excludeTags?: ESel; }): ExifCollectionDefinition<z.ZodObject<any, any, any, ExtractAllExifDataNoRaw<ESel>>>; declare function defineExifCollection<const TSel extends readonly ExifToolTagKeys[] | undefined = undefined, const PSel extends readonly ExifPresets[] | undefined = undefined, const ESel extends readonly ExifToolTagKeys[] | undefined = undefined>(options: ExifLoaderOptions & { tags?: TSel; presets?: PSel; excludeTags?: ESel; extractAll?: false; includeRawExif: true; }): ExifCollectionDefinition<z.ZodObject<any, any, any, NarrowedExifData<MaybeUndefinedSelected<TSel, PSel>, ESel>>>; declare function defineExifCollection<const TSel extends readonly ExifToolTagKeys[] | undefined = undefined, const PSel extends readonly ExifPresets[] | undefined = undefined, const ESel extends readonly ExifToolTagKeys[] | undefined = undefined>(options?: ExifLoaderOptions & { tags?: TSel; presets?: PSel; excludeTags?: ESel; extractAll?: false; includeRawExif?: false; }): ExifCollectionDefinition<z.ZodObject<any, any, any, NarrowedExifDataNoRaw<MaybeUndefinedSelected<TSel, PSel>, ESel>>>; export { createExifLoader, defineExifCollection, exifSchema };