/** * State object * @typedef {Object} ImageState * @property data - the result of the image operation * @property references - an array of all previous data objects used in the Job * @private **/ /** * Resize an image to the given dimensions. * Writes `{ buffer, width, height }` to `state.data`. * @public * @example * resize($.data.photoBase64, { width: 1200, height: 1600 }) * @function * @param {string|Buffer|Function} base64ImgOrBuffer - Base64 string, data URL, Buffer, or resolver fn * @param {object} [options={}] * @param {number} [options.width] - Output width in pixels * @param {number} [options.height] - Output height in pixels * @param {'buffer'|'base64'} [options.parseAs='buffer'] - Return format: `'buffer'` (default) or `'base64'` * @state {ImageState} * @returns {Operation} */ export function resize(base64ImgOrBuffer: string | Buffer | Function, options?: { width?: number; height?: number; parseAs?: 'buffer' | 'base64'; }): Operation; /** * Compress an image by reducing image quality until it reaches the criteria. * Writes `{ buffer, size, quality }` to `state.data`. * @public * @example * compress(state.data.buffer, { maxBytes: 700 * 1024, minQuality: 20 }) * @function * @param {string|Buffer|Function} base64ImgOrBuffer - Base64 string, data URL, Buffer, or resolver fn * @param {object} [options={}] * @param {number} [options.maxBytes=716800] - Maximum output file size in bytes * @param {number} [options.minQuality=20] - JPEG quality floor (1–100); compression stops here even if maxBytes is not met * @param {'buffer'|'base64'} [options.parseAs='buffer'] - Return format: `'buffer'` (default) or `'base64'` * @state {ImageState} * @returns {Operation} */ export function compress(base64ImgOrBuffer: string | Buffer | Function, options?: { maxBytes?: number; minQuality?: number; parseAs?: 'buffer' | 'base64'; }): Operation; /** * Strip all EXIF metadata from an image. Output is always a JPEG buffer. * Writes `{ buffer }` to `state.data`. * @public * @example * stripMetadata($.data.photoBase64) * @function * @param {string|Buffer|Function} base64ImgOrBuffer - Base64 string, data URL, Buffer, or resolver fn * @param {object} [options={}] * @param {'buffer'|'base64'} [options.parseAs='buffer'] - Return format: `'buffer'` (default) or `'base64'` * @state {ImageState} * @returns {Operation} */ export function stripMetadata(base64ImgOrBuffer: string | Buffer | Function, options?: { parseAs?: 'buffer' | 'base64'; }): Operation; /** * Embed EXIF metadata into a JPEG image. * Writes `{ buffer }` to `state.data`. * @public * @example * embedMetadata($.data.buffer, { UserComment: 'patient-id=42' }) * embedMetadata($.data.buffer, { UserComment: 'patient-id=42', Make: 'OpenFn' }, { parseAs: 'base64' }) * @function * @param {string|Buffer|Function} base64ImgOrBuffer - Base64 string, data URL, Buffer, or resolver fn * @param {object} exifObj - EXIF key-value pairs; keys must be valid EXIF tag names (e.g. UserComment, Make, Model) * @param {object} [options={}] * @param {'buffer'|'base64'} [options.parseAs='buffer'] - Return format: `'buffer'` (default) or `'base64'` * @state {ImageState} * @returns {Operation} */ export function embedMetadata(base64ImgOrBuffer: string | Buffer | Function, exifObj: object, options?: { parseAs?: 'buffer' | 'base64'; }): Operation; /** * Read image metadata without modifying the image. * Writes `{ width, height, orientation, size, exif }` to `state.data`. * `exif` is a flat object of human-readable EXIF tag names (e.g. `{ Make, Model, GPSLatitude, UserComment }`). * `UserComment` has the `ASCII\0\0\0` encoding prefix stripped. Images with no EXIF return `exif: {}`. * @public * @example * metadata($.data.photoBase64) * fn(state => { * if (state.data.size > 700 * 1024) { ... } * return state; * }) * @function * @param {string|Buffer|Function} base64ImgOrBuffer - Base64 string, data URL, Buffer, or resolver fn * @state {ImageState} * @returns {Operation} */ export function metadata(base64ImgOrBuffer: string | Buffer | Function): Operation; /** * State object */ export type ImageState = { /** * - the result of the image operation */ data: any; /** * - an array of all previous data objects used in the Job */ references: any; }; export { as, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, lastReferenceValue, map, merge, scrubEmojis, sourceValue, util, http } from "@openfn/language-common";