UNPKG

@aidin36/xmp

Version:

Read and write XMP metadata from/to various media formats

99 lines (98 loc) 4.31 kB
import { XMP } from '@aidin36/xmp2js'; export { XMP, XMPNode } from '@aidin36/xmp2js'; /** * This is the most portable way of reading the data. Because not every * Javascript environment supports TextDecoder. In those cases, you can call * this function and decode the output using what is available. * * If your environment has TextDecoder, or if you have a polyfill of it in your * application, you can use 'readXmpFromJpegBinary' function to get a decoded * string. * * Note that the output is encoded as UTF-8. Javascript's strings are UTF-16. * So you need to decode the output from UTF-8. * * @param image - Data of the JPEG image in the form of Uint8Array * @returns XMP as a UTF-8 byte array, or undefined if no XMP data found in the * provided file. */ export declare const readXmpFromJpegAsBinary: (image: Uint8Array) => Uint8Array | undefined; /** * Extracts the XMP string from a JPEG file. * It returns the string as-is without modifications. * * Note that your Javascript environment should provide TextDecoder or a * polyfill of it. * * @param image - Data of the JPEG image in the form of Uint8Array * @returns XMP as a string, or undefined if no XMP data found in the provided file. */ export declare const readXmpFromJpeg: (image: Uint8Array) => string | undefined; /** * Extracts the XMP from a JPEG file, and transforms it to a JS Object. * It uses the '@aidin36/xmp2js' for the transformation. You can read the documents * of '@aidin36/xmp2js' to learn more about the output format. * * @param image - Data of the JPEG image in the form of Uint8Array * @returns A JS Object, or undefined if no XMP data found in the provided file. */ export declare const readXmpFromJpegAsJs: (image: Uint8Array) => XMP | undefined; /** * This is the most portable way of reading the data. Because not every * Javascript environment supports TextDecoder. In those cases, you can call * this function and decode the output using what is available. * * If your environment has TextDecoder, or if you have a polyfill of it in your * application, you can use 'readXmpFromHeic' function to get a decoded string. * * Note that the output is encoded as UTF-8. Javascript's strings are UTF-16. * So you need to decode the output from UTF-8. * * @param image - Data of the HEIC image in the form of Uint8Array * @returns XMP as a UTF-8 byte array, or undefined if no XMP data found in the * provided file. */ export declare const readXmpFromHeicAsBinary: (image: Uint8Array) => Uint8Array | undefined; /** * Extracts the XMP string from a HEIC file. * It returns the string as-is without modifications. * * Note that your Javascript environment should provide TextDecoder. * * @param image - Data of the HEIC image in the form of Uint8Array * @returns XMP as a string, or undefined if no XMP data found in the provided file. */ export declare const readXmpFromHeic: (image: Uint8Array) => string | undefined; /** * Extracts the XMP string from a HEIC file, then converts it to a Javascript * Object. * It uses the '@aidin36/xmp2js' for the transformation. You can read the documents * of '@aidin36/xmp2js' to learn more about the output format. * * Note that your Javascript environment should provide TextDecoder. * * @param image - Data of the HEIC image in the form of Uint8Array * @returns A JS Object, or undefined if no XMP data found in the provided file. */ export declare const readXmpFromHeicAsJs: (image: Uint8Array) => XMP | undefined; /** * Writes the XMP data to an image file in HEIC format. * This is the most portable overload. Because not every Javascript * environment supports TextEncoder. In those cases, you can encode your * XMP with what is available and pass it. * * Note that XMP needs to be in UTF-8 encoding. * * @param image - Data of the HEIC image in the form of Uint8Array * @param xmp - Encoded XMP * @returns The modified image */ export declare const writeXmpToHeic: (image: Uint8Array, xmp: Uint8Array) => Uint8Array; /** * Writes the XMP data to an image file in HEIC format. * * @param image - Data of the HEIC image in the form of Uint8Array * @param xmp - Encoded XMP * @returns The modified image */ export declare const writeXmpToHeicAsString: (image: Uint8Array, xmp: string) => Uint8Array;